bgneal@515: """ bgneal@515: Tests for the pick_potd() function. bgneal@515: bgneal@515: """ bgneal@515: from django.test import TestCase bgneal@515: from django.contrib.auth.models import User bgneal@515: bgneal@515: from potd.models import Current, Photo, Sequence bgneal@515: from potd.tools import pick_potd bgneal@515: bgneal@515: bgneal@515: class PickPotdTest(TestCase): bgneal@515: bgneal@515: fixtures = ['potd_test.json'] bgneal@515: bgneal@515: def test_pick(self): bgneal@515: bgneal@515: pick_potd() bgneal@515: bgneal@515: curr = Current.objects.get(pk=1) bgneal@515: self.assertEqual(curr.potd.pk, 2) bgneal@515: bgneal@515: def test_shuffle(self): bgneal@515: bgneal@515: photo = Photo.objects.get(pk=3) bgneal@515: curr = Current.objects.get(pk=1) bgneal@515: curr.potd = photo bgneal@515: curr.save() bgneal@515: bgneal@515: pick_potd() bgneal@515: bgneal@515: ids = Sequence.objects.get(pk=1).seq.split(',') bgneal@515: curr = Current.objects.get(pk=1) bgneal@515: self.assertEqual(len(ids), 3) bgneal@515: self.assertEqual(curr.potd.pk, int(ids[0]))