Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Oppenheimer authored and Aaron Oppenheimer committed Jul 14, 2024
1 parent d6d9b46 commit cdefddc
Showing 1 changed file with 15 additions and 28 deletions.
43 changes: 15 additions & 28 deletions agenda/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from gig.tests import GigTestBase
from gig.util import GigStatusChoices, PlanStatusChoices
from gig.models import Plan
from member.util import AgendaLayoutChoices, AgendaPanelTypes
from member.util import AgendaLayoutChoices
from agenda.helpers import _get_agenda_plans
from band.models import Band, Assoc
from band.util import AssocStatusChoices
Expand All @@ -40,7 +40,7 @@ def test_agenda_types(self):
self.joeuser.preferences.save()

# get as a single list
response = c.get(f'/plans/{int(AgendaPanelTypes.ONE_LIST)}/0')
response = c.get(f'/plans/{int(AgendaLayoutChoices.ONE_LIST)}/0')
self.assertEqual(response.content.decode('ascii').count("xyzzy"), 19)

# test "has plans" vs. "doesn't have plans"
Expand All @@ -50,19 +50,15 @@ def test_agenda_types(self):
plan.status = PlanStatusChoices.DEFINITELY
plan.save()

response = c.get(f'/plans/{int(AgendaPanelTypes.NEEDS_RESPONSE)}/0')
response = c.get(f'/plans/{int(AgendaLayoutChoices.NEED_RESPONSE)}/0')
self.assertEqual(response.content.decode('ascii').count("xyzzy"), 18)
response = c.get(f'/plans/{int(AgendaPanelTypes.HAS_RESPONSE)}/0')
self.assertEqual(response.content.decode('ascii').count("xyzzy"), 1)

# now make sure that a gig that is canceled is moved to the "plans" set even
# though it has no plans...
gigs[1].status = GigStatusChoices.CANCELED
gigs[1].save()
response = c.get(f'/plans/{int(AgendaPanelTypes.NEEDS_RESPONSE)}/0')
response = c.get(f'/plans/{int(AgendaLayoutChoices.NEED_RESPONSE)}/0')
self.assertEqual(response.content.decode('ascii').count("xyzzy"), 17)
response = c.get(f'/plans/{int(AgendaPanelTypes.HAS_RESPONSE)}/0')
self.assertEqual(response.content.decode('ascii').count("xyzzy"), 2)


def test_agenda_occasionals(self):
Expand Down Expand Up @@ -115,14 +111,14 @@ def test_hide_band_from_calendar_preference(self):
c = Client()
c.force_login(self.joeuser)
# first 'page' of gigs should show the gig
response = c.get(f'/plans/{int(AgendaPanelTypes.NEEDS_RESPONSE)}/0')
response = c.get(f'/plans/{int(AgendaLayoutChoices.NEED_RESPONSE)}/0')

self.assertEqual(response.content.decode('ascii').count("xyzzy"), 1)

a.hide_from_schedule = True
a.save()
# first 'page' of gigs should not show the gig
response = c.get(f'/plans/{int(AgendaPanelTypes.NEEDS_RESPONSE)}/0')
response = c.get(f'/plans/{int(AgendaLayoutChoices.NEED_RESPONSE)}/0')
self.assertEqual(response.content.decode('ascii').count("xyzzy"), 0)

def test_agenda_page_types(self):
Expand Down Expand Up @@ -162,13 +158,13 @@ def test_agenda_page_types(self):
# test single list with all bands
a2.hide_from_schedule = False
a2.save()
the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.ONE_LIST, 0)
the_list, _ = _get_agenda_plans(joe, AgendaLayoutChoices.ONE_LIST, 0)
self.assertEqual(len(the_list), 6)

# test single list with a hidden band
a2.hide_from_schedule = True
a2.save()
the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.ONE_LIST, 0)
the_list, _ = _get_agenda_plans(joe, AgendaLayoutChoices.ONE_LIST, 0)
self.assertEqual(len(the_list), 3)

a2.hide_from_schedule = False
Expand All @@ -181,29 +177,20 @@ def test_agenda_page_types(self):
p.status = PlanStatusChoices.DEFINITELY
p.save()

the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.NEEDS_RESPONSE, 0)
the_list, _ = _get_agenda_plans(joe, AgendaLayoutChoices.NEED_RESPONSE, 0)
self.assertEqual(len(the_list), 5)

the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.HAS_RESPONSE, 0)
self.assertEqual(len(the_list), 1)

# test ditto with hidden band
a2.hide_from_schedule = True
a2.save()

the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.NEEDS_RESPONSE, 0)
the_list, _ = _get_agenda_plans(joe, AgendaLayoutChoices.NEED_RESPONSE, 0)
self.assertEqual(len(the_list), 2)

the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.HAS_RESPONSE, 0)
self.assertEqual(len(the_list), 1)

a1.hide_from_schedule = True
a1.save()

the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.NEEDS_RESPONSE, 0)
self.assertEqual(len(the_list), 0)

the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.HAS_RESPONSE, 0)
the_list, _ = _get_agenda_plans(joe, AgendaLayoutChoices.NEED_RESPONSE, 0)
self.assertEqual(len(the_list), 0)

a1.hide_from_schedule = False
Expand All @@ -212,20 +199,20 @@ def test_agenda_page_types(self):
a2.save()

# test split by band
the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.ONE_BAND, b1.id)
the_list, _ = _get_agenda_plans(joe, AgendaLayoutChoices.BY_BAND, b1.id)
self.assertEqual(len(the_list), 3)

the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.ONE_BAND, b2.id)
the_list, _ = _get_agenda_plans(joe, AgendaLayoutChoices.BY_BAND, b2.id)
self.assertEqual(len(the_list), 3)

# test ditto with hidden band
a2.hide_from_schedule = True
a2.save()

the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.ONE_BAND, b1.id)
the_list, _ = _get_agenda_plans(joe, AgendaLayoutChoices.BY_BAND, b1.id)
self.assertEqual(len(the_list), 3)

the_list, _ = _get_agenda_plans(joe, AgendaPanelTypes.ONE_BAND, b2.id)
the_list, _ = _get_agenda_plans(joe, AgendaLayoutChoices.BY_BAND, b2.id)
self.assertEqual(len(the_list), 0)


Expand Down

0 comments on commit cdefddc

Please sign in to comment.