Mercurial > public > sg101
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/potd/tests/test_tools.py Sun Dec 29 14:45:26 2013 -0600 @@ -0,0 +1,34 @@ +""" +Tests for the pick_potd() function. + +""" +from django.test import TestCase + +from potd.models import Current, Photo, Sequence +from potd.tools import pick_potd + + +class PickPotdTest(TestCase): + + fixtures = ['potd_test.json'] + + def test_pick(self): + + pick_potd() + + curr = Current.objects.get(pk=1) + self.assertEqual(curr.potd.pk, 2) + + def test_shuffle(self): + + photo = Photo.objects.get(pk=3) + curr = Current.objects.get(pk=1) + curr.potd = photo + curr.save() + + pick_potd() + + ids = Sequence.objects.get(pk=1).seq.split(',') + curr = Current.objects.get(pk=1) + self.assertEqual(len(ids), 3) + self.assertEqual(curr.potd.pk, int(ids[0]))