Ejemplo n.º 1
0
    def test_creation(self):
        """ Create constituency, save in database, retrieve """

        constituency = Constituency(name="Merthyr Tydfil and Rhymney")
        self.assertIsNone(constituency.id)
        constituency.save()
        self.assertIsNotNone(constituency.id)
        self.assertIs(type(constituency.id), int)

        constituency_again = Constituency.objects.get(id=constituency.id)
        self.assertEqual(constituency.name, constituency_again.name)
Ejemplo n.º 2
0
    def test_creation(self):
        """ Create answerset """

        constituency = Constituency(name="Merthyr Tydfil and Rhymney")
        constituency.save()

        party = Party(name="Plaid Cymru", abbreviation="PC")
        party.save()

        answers = AnswerSet(
            constituency=constituency,
            going_to_vote="yes",
            voting_for=party
        )
        answers.save()