class LynchingTest(TestCase): fixtures = ['demographics.json',] def setUp(self): # Setup other related objects county = County.objects.get(name="Decatur") acc = Accusation(**accusation1) acc.save() race = Race(**race1) race.save() #Lynching self.lynching = Lynching(pca_id="22394") self.lynching.save() # Named Victim self.victim1 = Victim(**named_victim) self.victim1.save() self.victim1.county = county self.victim1.accusation.add(acc) self.victim1.race = race self.victim1.lynching = self.lynching self.victim1.save() # Unnamed Victim self.victim2 = Victim(**unnamed_victim) self.victim2.save() self.victim2.county = county self.victim2.accusation.add(acc) self.victim2.race = race self.victim2.lynching = self.lynching self.victim2.save() def test_pretty_string(self): expected = "Lynching of Test Victim, Unknown test race Male in 1893" self.assertEqual(expected, self.lynching.pretty_string) def test_county_list(self): expected = "Decatur" county_names = [county.name for county in self.lynching.county_list] self.assertTrue(expected in county_names) def test_year(self): expected = 1893 self.assertEqual(expected, self.lynching.year) self.victim2.date = date(1923, 02, 10) self.victim2.save() self.assertEqual(1923, self.lynching.year)
def setUp(self): # Setup other related objects county = County.objects.get(name="Decatur") acc = Accusation(**accusation1) acc.save() race = Race(**race1) race.save() #Lynching self.lynching = Lynching(pca_id="22394") self.lynching.save() # Named Victim self.victim1 = Victim(**named_victim) self.victim1.save() self.victim1.county = county self.victim1.accusation.add(acc) self.victim1.race = race self.victim1.lynching = self.lynching self.victim1.save() # Unnamed Victim self.victim2 = Victim(**unnamed_victim) self.victim2.save() self.victim2.county = county self.victim2.accusation.add(acc) self.victim2.race = race self.victim2.lynching = self.lynching self.victim2.save()