Skip to content

Commit

Permalink
Fix a bunch of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gannetson committed Sep 9, 2022
1 parent d42b719 commit f7f4f1c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 31 deletions.
12 changes: 4 additions & 8 deletions bluebottle/activities/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from django.test import TestCase

from bluebottle.initiatives.tests.factories import InitiativeFactory
from bluebottle.offices.tests.factories import LocationFactory
from bluebottle.segments.tests.factories import SegmentFactory, SegmentTypeFactory
from bluebottle.test.factory_models.accounts import BlueBottleUserFactory
from bluebottle.time_based.tests.factories import PeriodActivityFactory, PeriodParticipantFactory


class ActivitySegmentsTestCase(TestCase):
def setUp(self):

team_type = SegmentTypeFactory.create(name='Team')
self.team = SegmentFactory.create(name='Online Marketing', segment_type=team_type)
self.other_team = SegmentFactory.create(name='Direct Marketing', segment_type=team_type)
Expand Down Expand Up @@ -64,15 +63,12 @@ def test_delete_segment(self):
self.assertFalse(self.team in activity.segments.all())

def test_office_location_required(self):
activity = PeriodActivityFactory.create(
initiative=InitiativeFactory.create()
)
LocationFactory.create_batch(3)
activity = PeriodActivityFactory.create()
self.assertTrue('office_location' in activity.required_fields)

def test_office_location_not_required(self):
activity = PeriodActivityFactory.create(
initiative=InitiativeFactory.create()
)
activity = PeriodActivityFactory.create()
self.assertFalse('office_location' in activity.required_fields)

def test_is_team_captain_no_team(self):
Expand Down
2 changes: 1 addition & 1 deletion bluebottle/exports/tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_export(self):
)
self.assertEqual(
book.sheet_by_name('Activities on a date').cell(0, 9).value,
'Office location'
'Office Location'
)
self.assertEqual(
book.sheet_by_name('Activities on a date').cell(0, 10).value,
Expand Down
7 changes: 4 additions & 3 deletions bluebottle/funding_flutterwave/triggers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from bluebottle.fsm.triggers import (
TransitionTrigger, register, TriggerManager
TransitionTrigger, register
)
from bluebottle.funding.triggers import BankAccountTriggers
from bluebottle.funding_flutterwave.effects import MigrateToLipishaEffect
from bluebottle.funding_flutterwave.models import FlutterwaveBankAccount
from bluebottle.funding_flutterwave.states import FlutterwaveBankAccountStateMachine


@register(FlutterwaveBankAccount)
class FlutterwaveBankAccountTriggers(TriggerManager):
triggers = [
class FlutterwaveBankAccountTriggers(BankAccountTriggers):
triggers = BankAccountTriggers.triggers + [
TransitionTrigger(
FlutterwaveBankAccountStateMachine.migrate_to_lipisha,
effects=[
Expand Down
7 changes: 4 additions & 3 deletions bluebottle/funding_lipisha/triggers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from bluebottle.fsm.triggers import (
TransitionTrigger, register, TriggerManager
TransitionTrigger, register
)
from bluebottle.funding.triggers import BankAccountTriggers
from bluebottle.funding_lipisha.effects import GenerateLipishaAccountsEffect
from bluebottle.funding_lipisha.models import LipishaBankAccount
from bluebottle.funding_lipisha.states import LipishaBankAccountStateMachine


@register(LipishaBankAccount)
class LipishaBankAccountTriggers(TriggerManager):
triggers = [
class LipishaBankAccountTriggers(BankAccountTriggers):
triggers = BankAccountTriggers.triggers + [

TransitionTrigger(
LipishaBankAccountStateMachine.verify,
Expand Down
18 changes: 7 additions & 11 deletions bluebottle/geo/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,16 @@ def setUp(self):
description="Description {}".format(i))
)

def test_api_location_list_endpoint(self):
"""
Ensure get request returns 200.
"""
response = self.client.get(reverse('office-list'))
def test_api_location_detail_endpoint(self):
location = self.locations[0]
response = self.client.get(reverse('office-detail', args=(location.id, )))

self.assertEqual(response.status_code, status.HTTP_200_OK)
data = response.json()

self.assertEqual(len(data['data']), 10)
self.assertEqual(data['data'][0]['attributes']['name'], self.locations[0].name)
self.assertEqual(data['data'][0]['attributes']['description'], self.locations[0].description)
data = response.json()['data']
self.assertEqual(data['attributes']['name'], self.locations[0].name)
self.assertEqual(data['attributes']['description'], self.locations[0].description)

static_map_url = data['data'][0]['attributes']['static-map-url']
static_map_url = data['attributes']['static-map-url']
self.assertTrue(
static_map_url.startswith('https://maps.googleapis.com/maps/api/staticmap?')
)
Expand Down
7 changes: 2 additions & 5 deletions bluebottle/time_based/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,10 @@ def test_admin_can_delete_activity(self):

def test_list_activities_office(self):
office = LocationFactory.create(name='Schin op Geul')
initiative = InitiativeFactory.create(location=office)
PeriodActivityFactory.create(initiative=initiative)
PeriodActivityFactory.create(office_location=office)
url = reverse('admin:time_based_periodactivity_changelist')
response = self.app.get(url)
self.assertEqual(len(response.html.find_all("a", string="Schin op Geul")), 2)
response = self.app.get(url)
self.assertEqual(len(response.html.find_all("a", string="Schin op Geul")), 2)
self.assertEqual(len(response.html.find_all("a", string="Schin op Geul")), 1)


class DateActivityAdminScenarioTestCase(BluebottleAdminTestCase):
Expand Down

0 comments on commit f7f4f1c

Please sign in to comment.