Пример #1
0
 def test_add_duplicate_town(self):
     t = Town('Test Town')
     s = State('Test State')
     s._add_town(t)
     with pytest.raises(ValueError) as verr:
         s._add_town(t)
     assert 'Town already exists' in str(verr.value)
Пример #2
0
 def test_lookup_town(self):
     s = State('Test State')
     s.process_record("Test Town", "Test District", "HS", "9-12")
     t = s._towns['Test Town']
     assert s.lookup_town("Test Town") is t
Пример #3
0
 def test_lookup_fail_bad_town(self):
     s = State('Test State')
     s.process_record("Test Town", "Test District", "HS", "9-12")
     with pytest.raises(KeyError) as verr:
         s.lookup_town("Test Towns", 8)
     assert "Town not present" in str(verr.value)
Пример #4
0
 def test_lookup_fail_bad_grade(self):
     s = State('Test State')
     s.process_record("Test Town", "Test District", "HS", "9-12")
     with pytest.raises(ValueError) as verr:
         s.lookup_town("Test Town", 8)
     assert "Grade not found" in str(verr.value)
Пример #5
0
 def test_lookup_grade_as_string(self):
     s = State('Test State')
     s.process_record("Test Town", "Test District", "HS", "9-12")
     assert s.lookup_town("Test Town", '9') is "Test District"
Пример #6
0
 def test_process_record_fails(self):
     s = State('Test State')
     with pytest.raises(ValueError) as verr:
         s.process_record("Test Town", "Test District", "HS", "9-12")
         s.process_record("Test Town", "Test District", "HS", "9-12")
     assert 'District has already been added' in str(verr.value)
Пример #7
0
 def test_process_record(self):
     s = State('Test State')
     s.process_record("Test Town", "Test District", "HS", "9-12")
Пример #8
0
 def test_add_town(self):
     t = Town('Test Town')
     s = State('Test State')
     s._add_town(t)
     assert t in s.towns
Пример #9
0
 def test_repr(self):
     s = State('Test State')
     assert s.__repr__() == 'Test State'