annotate potd/tests/test_receivers.py @ 943:cf9918328c64
Haystack tweaks for Django 1.7.7.
I had to upgrade to Haystack 2.3.1 to get it to work with Django
1.7.7. I also had to update the Xapian backend. But I ran into
problems.
On my laptop anyway (Ubuntu 14.0.4), xapian gets mad when search terms
are greater than 245 chars (or something) when indexing. So I created
a custom field that would simply omit terms greater than 64 chars and
used this field everywhere I previously used a CharField.
Secondly, the custom search form was broken now. Something changed in
the Xapian backend and exact searches stopped working. Fortunately the
auto_query (which I was using originally and broke during an upgrade)
started working again. So I cut the search form back over to doing an
auto_query. I kept the form the same (3 fields) because I didn't want
to change the form and I think it's better that way.
author |
Brian Neal <bgneal@gmail.com> |
date |
Wed, 13 May 2015 20:25:07 -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')
|