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