Mercurial > public > sg101
annotate potd/tests/tools_tests.py @ 637:8cce523096c8
Updated the store page for buttons & stickers.
Also added an "Editor's Choice" list of stuff to buy.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 16 Feb 2013 15:11:19 -0600 |
parents | ee87ea74d46b |
children |
rev | line source |
---|---|
bgneal@515 | 1 """ |
bgneal@515 | 2 Tests for the pick_potd() function. |
bgneal@515 | 3 |
bgneal@515 | 4 """ |
bgneal@515 | 5 from django.test import TestCase |
bgneal@515 | 6 from django.contrib.auth.models import User |
bgneal@515 | 7 |
bgneal@515 | 8 from potd.models import Current, Photo, Sequence |
bgneal@515 | 9 from potd.tools import pick_potd |
bgneal@515 | 10 |
bgneal@515 | 11 |
bgneal@515 | 12 class PickPotdTest(TestCase): |
bgneal@515 | 13 |
bgneal@515 | 14 fixtures = ['potd_test.json'] |
bgneal@515 | 15 |
bgneal@515 | 16 def test_pick(self): |
bgneal@515 | 17 |
bgneal@515 | 18 pick_potd() |
bgneal@515 | 19 |
bgneal@515 | 20 curr = Current.objects.get(pk=1) |
bgneal@515 | 21 self.assertEqual(curr.potd.pk, 2) |
bgneal@515 | 22 |
bgneal@515 | 23 def test_shuffle(self): |
bgneal@515 | 24 |
bgneal@515 | 25 photo = Photo.objects.get(pk=3) |
bgneal@515 | 26 curr = Current.objects.get(pk=1) |
bgneal@515 | 27 curr.potd = photo |
bgneal@515 | 28 curr.save() |
bgneal@515 | 29 |
bgneal@515 | 30 pick_potd() |
bgneal@515 | 31 |
bgneal@515 | 32 ids = Sequence.objects.get(pk=1).seq.split(',') |
bgneal@515 | 33 curr = Current.objects.get(pk=1) |
bgneal@515 | 34 self.assertEqual(len(ids), 3) |
bgneal@515 | 35 self.assertEqual(curr.potd.pk, int(ids[0])) |