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)
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
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)
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)
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"
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)
def test_process_record(self): s = State('Test State') s.process_record("Test Town", "Test District", "HS", "9-12")
def test_add_town(self): t = Town('Test Town') s = State('Test State') s._add_town(t) assert t in s.towns
def test_repr(self): s = State('Test State') assert s.__repr__() == 'Test State'