comparison potd/tests/tools_tests.py @ 581:ee87ea74d46b

For Django 1.4, rearranged project structure for new manage.py.
author Brian Neal <bgneal@gmail.com>
date Sat, 05 May 2012 17:10:48 -0500
parents gpp/potd/tests/tools_tests.py@ae89ba801e8b
children
comparison
equal deleted inserted replaced
580:c525f3e0b5d0 581:ee87ea74d46b
1 """
2 Tests for the pick_potd() function.
3
4 """
5 from django.test import TestCase
6 from django.contrib.auth.models import User
7
8 from potd.models import Current, Photo, Sequence
9 from potd.tools import pick_potd
10
11
12 class PickPotdTest(TestCase):
13
14 fixtures = ['potd_test.json']
15
16 def test_pick(self):
17
18 pick_potd()
19
20 curr = Current.objects.get(pk=1)
21 self.assertEqual(curr.potd.pk, 2)
22
23 def test_shuffle(self):
24
25 photo = Photo.objects.get(pk=3)
26 curr = Current.objects.get(pk=1)
27 curr.potd = photo
28 curr.save()
29
30 pick_potd()
31
32 ids = Sequence.objects.get(pk=1).seq.split(',')
33 curr = Current.objects.get(pk=1)
34 self.assertEqual(len(ids), 3)
35 self.assertEqual(curr.potd.pk, int(ids[0]))