Skip to content

Commit 958a03d

Browse files
committed
Add tests for Race default total votes and add_result method
1 parent 69177e0 commit 958a03d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

elex4/tests/test_models.py

+21
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ def test_county_results_access(self):
4747

4848
class TestRace(TestCase):
4949

50+
def setUp(self):
51+
self.smith_result = {
52+
'date': '2012-11-06',
53+
'candidate': 'Smith, Joe',
54+
'party': 'Dem',
55+
'office': 'President',
56+
'county': 'Fairfax',
57+
'votes': 2000,
58+
}
59+
5060
def test_clean_office_rep(self):
5161
race = Race("2012-11-06", "U.S. Rep - 1")
5262
self.assertEquals(race.office, "U.S. House of Representatives")
@@ -56,3 +66,14 @@ def test_clean_office_other(self):
5666
race = Race("2012-11-06", "President")
5767
self.assertEquals(race.office, "President")
5868
self.assertEquals(race.district, "")
69+
70+
def test_total_votes_default(self):
71+
"Race total votes should default to zero"
72+
race = Race("2012-11-06", "President")
73+
self.assertEquals(race.total_votes, 0)
74+
75+
def test_total_votes_update(self):
76+
"Race.add_result should update total votes for each result"
77+
race = Race("2012-11-06", "President")
78+
race.add_result(self.smith_result)
79+
self.assertEquals(race.total_votes, 2000)

0 commit comments

Comments
 (0)