Show More
@@ -1,19 +1,19 b'' | |||
|
1 | 1 | {% extends "boards/thread.html" %} |
|
2 | 2 | |
|
3 | 3 | {% load i18n %} |
|
4 | 4 | {% load static from staticfiles %} |
|
5 | 5 | {% load board %} |
|
6 | 6 | {% load tz %} |
|
7 | 7 | |
|
8 | 8 | {% block thread_content %} |
|
9 | 9 | {% get_current_language as LANGUAGE_CODE %} |
|
10 | 10 | {% get_current_timezone as TIME_ZONE %} |
|
11 | 11 | |
|
12 | 12 | <div class="thread"> |
|
13 | 13 | {% for post in thread.get_top_level_replies %} |
|
14 |
{% post_view post moderator=moderator |
|
|
14 | {% post_view post moderator=moderator mode_tree=True %} | |
|
15 | 15 | {% endfor %} |
|
16 | 16 | </div> |
|
17 | 17 | |
|
18 | 18 | <script src="{% static 'js/thread.js' %}"></script> |
|
19 | 19 | {% endblock %} |
@@ -1,69 +1,69 b'' | |||
|
1 | 1 | import simplejson |
|
2 | 2 | |
|
3 | 3 | from django.test import TestCase |
|
4 | 4 | from boards.views import api |
|
5 | 5 | |
|
6 | 6 | from boards.models import Tag, Post |
|
7 | 7 | from boards.tests.mocks import MockRequest |
|
8 | 8 | from boards.utils import datetime_to_epoch |
|
9 | 9 | |
|
10 | 10 | |
|
11 | 11 | class ApiTest(TestCase): |
|
12 | 12 | def test_thread_diff(self): |
|
13 | 13 | tag = Tag.objects.create(name='test_tag') |
|
14 | 14 | opening_post = Post.objects.create_post(title='title', text='text', |
|
15 | 15 | tags=[tag]) |
|
16 | 16 | |
|
17 | 17 | req = MockRequest() |
|
18 |
req. |
|
|
18 | req.POST['thread'] = opening_post.id | |
|
19 | 19 | req.POST['uids'] = opening_post.uid |
|
20 | 20 | # Check the exact timestamp post was added |
|
21 | 21 | empty_response = api.api_get_threaddiff(req) |
|
22 | 22 | diff = simplejson.loads(empty_response.content) |
|
23 | 23 | self.assertEqual(0, len(diff['updated']), |
|
24 | 24 | 'There must be no updated posts in the diff.') |
|
25 | 25 | |
|
26 | 26 | uids = [opening_post.uid] |
|
27 | 27 | |
|
28 | 28 | reply = Post.objects.create_post(title='', |
|
29 | 29 | text='[post]%d[/post]\ntext' % opening_post.id, |
|
30 | 30 | thread=opening_post.get_thread()) |
|
31 | 31 | req = MockRequest() |
|
32 |
req. |
|
|
32 | req.POST['thread'] = opening_post.id | |
|
33 | 33 | req.POST['uids'] = ' '.join(uids) |
|
34 | 34 | # Check the timestamp before post was added |
|
35 | 35 | response = api.api_get_threaddiff(req) |
|
36 | 36 | diff = simplejson.loads(response.content) |
|
37 | 37 | self.assertEqual(2, len(diff['updated']), |
|
38 | 38 | 'There must be 2 updated posts in the diff.') |
|
39 | 39 | |
|
40 | 40 | # Reload post to get the new UID |
|
41 | 41 | opening_post = Post.objects.get(id=opening_post.id) |
|
42 | 42 | req = MockRequest() |
|
43 |
req. |
|
|
43 | req.POST['thread'] = opening_post.id | |
|
44 | 44 | req.POST['uids'] = ' '.join([opening_post.uid, reply.uid]) |
|
45 | 45 | empty_response = api.api_get_threaddiff(req) |
|
46 | 46 | diff = simplejson.loads(empty_response.content) |
|
47 | 47 | self.assertEqual(0, len(diff['updated']), |
|
48 | 48 | 'There must be no updated posts in the diff.') |
|
49 | 49 | |
|
50 | 50 | def test_get_threads(self): |
|
51 | 51 | # Create 10 threads |
|
52 | 52 | tag = Tag.objects.create(name='test_tag') |
|
53 | 53 | for i in range(5): |
|
54 | 54 | Post.objects.create_post(title='title', text='text', tags=[tag]) |
|
55 | 55 | |
|
56 | 56 | # Get all threads |
|
57 | 57 | response = api.api_get_threads(MockRequest(), 5) |
|
58 | 58 | diff = simplejson.loads(response.content) |
|
59 | 59 | self.assertEqual(5, len(diff), 'Invalid thread list response.') |
|
60 | 60 | |
|
61 | 61 | # Get less threads then exist |
|
62 | 62 | response = api.api_get_threads(MockRequest(), 3) |
|
63 | 63 | diff = simplejson.loads(response.content) |
|
64 | 64 | self.assertEqual(3, len(diff), 'Invalid thread list response.') |
|
65 | 65 | |
|
66 | 66 | # Get more threads then exist |
|
67 | 67 | response = api.api_get_threads(MockRequest(), 10) |
|
68 | 68 | diff = simplejson.loads(response.content) |
|
69 | 69 | self.assertEqual(5, len(diff), 'Invalid thread list response.') |
General Comments 0
You need to be logged in to leave comments.
Login now