Slide 12
Slide 12 text
A sample fixture test
from django_dynamic_fixture import G
class ChoiceModelTest(TestCase):
def test_choice_creation(self):
# set up the values
poll0 = G(Poll)
poll1 = G(Poll)
ch0 = G(Choice, poll=poll0)
ch1 = G(Choice, poll=poll0)
# test basic values
polls_in_db = Poll.objects.all()
poll_zero = polls_in_db[0]
poll_one = polls_in_db[1]
choices = Choice.objects.filter(poll = poll_zero)
self.assertEquals(choices.count(), 4)
ch_zero = choices[0]
self.assertEquals(ch_zero.choice, ch0.choice)
self.assertEquals(ch_zero.votes, ch0.votes)