Mercurial > public > sg101
changeset 933:0aa9aeaa98a6
Add tests for potd signal handlers.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 16 Apr 2015 19:35:08 -0500 |
parents | 92b4baa0383b |
children | 9d6c2ed2f348 |
files | potd/tests/test_receivers.py |
diffstat | 1 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/potd/tests/test_receivers.py Thu Apr 16 19:35:08 2015 -0500 @@ -0,0 +1,34 @@ +"""Tests for potd signal handlers.""" +from django.contrib.auth.models import User +from django.test import TestCase + +from mock import Mock + +from potd.models import Photo, Sequence, Current + + +class PotdSignalRcvrTestCase(TestCase): + + fixtures = ['potd_test.json'] + + def test_on_photo_save(self): + user = User.objects.get(pk=1) + photo = Photo(photo='/tmp/1.jpg', + caption='caption', + description='desc', + user=user) + photo.generate_thumb = Mock() + photo.save() + + current = Current.objects.get_current_id() + self.assertTrue(current != photo.pk) + + seq = Sequence.objects.get(pk=1) + expected = '1,{},2,3'.format(photo.pk) + self.assertEqual(seq.seq, expected) + + def test_on_photo_delete(self): + photo = Photo.objects.get(pk=2) + photo.delete() + seq = Sequence.objects.get(pk=1) + self.assertEqual(seq.seq, '1,3')