Skip to content

Commit d9d5bbd

Browse files
committed
update test
1 parent 7d76ace commit d9d5bbd

1 file changed

Lines changed: 38 additions & 7 deletions

File tree

nominations/tests/test_roster_views.py

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ def test_year_displayed(self):
5858
"""Fellow year elected should be displayed in parentheses."""
5959
Fellow.objects.create(name="Year Fellow", year_elected=2019, status="active")
6060
response = self.client.get(self.url)
61-
self.assertContains(response, "Year Fellow (2019)")
61+
self.assertContains(response, "(2019)")
6262

6363
def test_emeritus_year_displayed(self):
64-
"""Emeritus fellows should show both elected and emeritus year."""
64+
"""Emeritus fellows should show elected year, en-dash, and emeritus year."""
6565
Fellow.objects.create(name="Old Fellow", year_elected=2005, status="emeritus", emeritus_year=2020)
6666
response = self.client.get(self.url)
67-
self.assertContains(response, "Old Fellow (2005/2020)")
67+
self.assertContains(response, "Old Fellow")
68+
# Template uses – HTML entity for en-dash separator
69+
self.assertContains(response, "(2005–2020)")
6870

6971
def test_deceased_notes_displayed(self):
7072
"""Deceased fellows should show notes if present."""
@@ -90,12 +92,41 @@ def test_sections_in_context(self):
9092
self.assertEqual(response.context["deceased_count"], 1)
9193
self.assertEqual(response.context["total_count"], 4)
9294

93-
def test_section_headings_rendered(self):
94-
"""Each section heading should appear when fellows of that status exist."""
95+
def test_status_tabs_rendered(self):
96+
"""Status tab buttons should appear when fellows exist."""
9597
Fellow.objects.create(name="Active Fellow", year_elected=2020, status="active")
9698
Fellow.objects.create(name="Emeritus Fellow", year_elected=2010, status="emeritus")
9799
Fellow.objects.create(name="Deceased Fellow", year_elected=2005, status="deceased")
98100
response = self.client.get(self.url)
99-
self.assertContains(response, "Fellows (1)")
100-
self.assertContains(response, "Emeritus Fellows (1)")
101+
self.assertContains(response, "Active (1)")
102+
self.assertContains(response, "Emeritus (1)")
101103
self.assertContains(response, "In Memoriam (1)")
104+
105+
def test_years_in_context(self):
106+
"""Context should include distinct years sorted descending."""
107+
Fellow.objects.create(name="Fellow A", year_elected=2015, status="active")
108+
Fellow.objects.create(name="Fellow B", year_elected=2020, status="active")
109+
Fellow.objects.create(name="Fellow C", year_elected=2015, status="emeritus")
110+
response = self.client.get(self.url)
111+
years = list(response.context["years"])
112+
self.assertEqual(years, [2020, 2015])
113+
114+
def test_data_attributes_rendered(self):
115+
"""Each fellow list item should have data-name, data-year, data-status attributes."""
116+
Fellow.objects.create(name="Data Fellow", year_elected=2021, status="active")
117+
response = self.client.get(self.url)
118+
self.assertContains(response, 'data-name="data fellow"')
119+
self.assertContains(response, 'data-year="2021"')
120+
self.assertContains(response, 'data-status="active"')
121+
122+
def test_emeritus_badge_shown(self):
123+
"""Emeritus fellows should have a badge."""
124+
Fellow.objects.create(name="Badge Fellow", year_elected=2010, status="emeritus")
125+
response = self.client.get(self.url)
126+
self.assertContains(response, "fellow-badge emeritus")
127+
128+
def test_deceased_badge_shown(self):
129+
"""Deceased fellows should have a badge."""
130+
Fellow.objects.create(name="Memorial Fellow", year_elected=2005, status="deceased")
131+
response = self.client.get(self.url)
132+
self.assertContains(response, "fellow-badge deceased")

0 commit comments

Comments
 (0)