Mercurial > public > sg101
annotate potd/tests/test_receivers.py @ 1111:96a72f0e6767
Remove bandmap.css.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 10 Jul 2016 21:58:22 -0500 |
parents | 0aa9aeaa98a6 |
children |
rev | line source |
---|---|
bgneal@933 | 1 """Tests for potd signal handlers.""" |
bgneal@933 | 2 from django.contrib.auth.models import User |
bgneal@933 | 3 from django.test import TestCase |
bgneal@933 | 4 |
bgneal@933 | 5 from mock import Mock |
bgneal@933 | 6 |
bgneal@933 | 7 from potd.models import Photo, Sequence, Current |
bgneal@933 | 8 |
bgneal@933 | 9 |
bgneal@933 | 10 class PotdSignalRcvrTestCase(TestCase): |
bgneal@933 | 11 |
bgneal@933 | 12 fixtures = ['potd_test.json'] |
bgneal@933 | 13 |
bgneal@933 | 14 def test_on_photo_save(self): |
bgneal@933 | 15 user = User.objects.get(pk=1) |
bgneal@933 | 16 photo = Photo(photo='/tmp/1.jpg', |
bgneal@933 | 17 caption='caption', |
bgneal@933 | 18 description='desc', |
bgneal@933 | 19 user=user) |
bgneal@933 | 20 photo.generate_thumb = Mock() |
bgneal@933 | 21 photo.save() |
bgneal@933 | 22 |
bgneal@933 | 23 current = Current.objects.get_current_id() |
bgneal@933 | 24 self.assertTrue(current != photo.pk) |
bgneal@933 | 25 |
bgneal@933 | 26 seq = Sequence.objects.get(pk=1) |
bgneal@933 | 27 expected = '1,{},2,3'.format(photo.pk) |
bgneal@933 | 28 self.assertEqual(seq.seq, expected) |
bgneal@933 | 29 |
bgneal@933 | 30 def test_on_photo_delete(self): |
bgneal@933 | 31 photo = Photo.objects.get(pk=2) |
bgneal@933 | 32 photo.delete() |
bgneal@933 | 33 seq = Sequence.objects.get(pk=1) |
bgneal@933 | 34 self.assertEqual(seq.seq, '1,3') |