##// END OF EJS Templates
Added signatures to the GET response. Added a view to get a full post response for one post. Don't show post key as it is present in the XML post view. Changed key display format
Added signatures to the GET response. Added a view to get a full post response for one post. Don't show post key as it is present in the XML post view. Changed key display format

File last commit:

r821:572aaa88 default
r837:fbeaaa16 decentral
Show More
test_api.py
49 lines | 2.3 KiB | text/x-python | PythonLexer
neko259
Split tests module into separate modules
r821 import simplejson
from django.test import TestCase
from boards.models import Tag, Post
from boards.tests.mocks import MockRequest
from boards.utils import datetime_to_epoch
from boards.views.api import api_get_threaddiff
class ApiTest(TestCase):
def test_thread_diff(self):
tag = Tag.objects.create(name='test_tag')
opening_post = Post.objects.create_post(title='title', text='text',
tags=[tag])
last_edit_time = datetime_to_epoch(opening_post.last_edit_time)
# Check the exact timestamp post was added
empty_response = api_get_threaddiff(MockRequest(),
str(opening_post.thread_new.id),
str(last_edit_time))
diff = simplejson.loads(empty_response.content)
self.assertEqual(0, len(diff['added']),
'There must be no added posts in the diff.')
self.assertEqual(0, len(diff['updated']),
'There must be no updated posts in the diff.')
reply = Post.objects.create_post(title='',
text='[post]%d[/post]\ntext' % opening_post.id,
thread=opening_post.thread_new)
# Check the timestamp before post was added
response = api_get_threaddiff(MockRequest(),
str(opening_post.thread_new.id),
str(last_edit_time))
diff = simplejson.loads(response.content)
self.assertEqual(1, len(diff['added']),
'There must be 1 added posts in the diff.')
self.assertEqual(1, len(diff['updated']),
'There must be 1 updated posts in the diff.')
empty_response = api_get_threaddiff(MockRequest(),
str(opening_post.thread_new.id),
str(datetime_to_epoch(reply.last_edit_time)))
diff = simplejson.loads(empty_response.content)
self.assertEqual(0, len(diff['added']),
'There must be no added posts in the diff.')
self.assertEqual(0, len(diff['updated']),
'There must be no updated posts in the diff.')