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()
class AccusationTest(TestCase):

    def setUp(self):
        self.acc = Accusation(label=accusation1["label"])
        self.acc.save()

    def test_string(self):
        expected = "Test Crime"
        self.assertEqual(expected, "%s" % self.acc)
 def _handle_accusation(self, victim, accusation_raw):
     """
     Tries to approximate a match of the accusation from the current values or creates one if no match found.
     """
     if not accusation_raw:
         return None
     accusation_text = accusation_raw.strip(' \t\n\r')
     try:
         accusation = Accusation.objects.get(label__iexact=accusation_text)
     except Accusation.DoesNotExist:
         accusation = Accusation(label=accusation_text)
         accusation.save()
     victim.accusation.add(accusation)
 def setUp(self):
     self.acc = Accusation(label=accusation1["label"])
     self.acc.save()