Mercurial > public > sg101
annotate potd/tests/tools_tests.py @ 661:15dbe0ccda95
Prevent exceptions when viewing downloads in the admin when the file
doesn't exist on the filesystem. This is usually seen in development
but can also happen in production if the file is missing.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 14 May 2013 21:02:47 -0500 |
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])) |