Skip to content

Commit d31c622

Browse files
committed
Add test for Race.office and district attributes
1 parent ad837a1 commit d31c622

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

elex4/tests/test_models.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from unittest import TestCase
22

3-
from elex4.lib.models import Candidate
3+
from elex4.lib.models import Candidate, Race
4+
45

56
class TestCandidate(TestCase):
67

@@ -42,3 +43,16 @@ def test_county_results_access(self):
4243
self.cand.add_votes("Some County", 20)
4344
expected = { "Some County": 20 }
4445
self.assertEquals(self.cand.county_results, expected)
46+
47+
48+
class TestRace(TestCase):
49+
50+
def test_clean_office_rep(self):
51+
race = Race("2012-11-06", "U.S. Rep - 1")
52+
self.assertEquals(race.office, "U.S. House of Representatives")
53+
self.assertEquals(race.district, 1)
54+
55+
def test_clean_office_other(self):
56+
race = Race("2012-11-06", "President")
57+
self.assertEquals(race.office, "President")
58+
self.assertEquals(race.district, None)

0 commit comments

Comments
 (0)