Mercurial > public > sg101
comparison potd/tests/test_tools.py @ 744:8789299c75b1
Django 1.6: test discovery as per unittest.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 29 Dec 2013 14:45:26 -0600 |
parents | potd/tests/tools_tests.py@ee87ea74d46b |
children |
comparison
equal
deleted
inserted
replaced
743:66d46d31d543 | 744:8789299c75b1 |
---|---|
1 """ | |
2 Tests for the pick_potd() function. | |
3 | |
4 """ | |
5 from django.test import TestCase | |
6 | |
7 from potd.models import Current, Photo, Sequence | |
8 from potd.tools import pick_potd | |
9 | |
10 | |
11 class PickPotdTest(TestCase): | |
12 | |
13 fixtures = ['potd_test.json'] | |
14 | |
15 def test_pick(self): | |
16 | |
17 pick_potd() | |
18 | |
19 curr = Current.objects.get(pk=1) | |
20 self.assertEqual(curr.potd.pk, 2) | |
21 | |
22 def test_shuffle(self): | |
23 | |
24 photo = Photo.objects.get(pk=3) | |
25 curr = Current.objects.get(pk=1) | |
26 curr.potd = photo | |
27 curr.save() | |
28 | |
29 pick_potd() | |
30 | |
31 ids = Sequence.objects.get(pk=1).seq.split(',') | |
32 curr = Current.objects.get(pk=1) | |
33 self.assertEqual(len(ids), 3) | |
34 self.assertEqual(curr.potd.pk, int(ids[0])) |