##// END OF EJS Templates
Logo rebranding
Logo rebranding

File last commit:

r1895:19684540 default
r2150:532ef623 tip default
Show More
test_api.py
70 lines | 2.8 KiB | text/x-python | PythonLexer
neko259
Split tests module into separate modules
r821 import simplejson
from django.test import TestCase
neko259
Added test for threads list API
r978 from boards.views import api
neko259
Split tests module into separate modules
r821
from boards.models import Tag, Post
from boards.tests.mocks import MockRequest
from boards.utils import datetime_to_epoch
class ApiTest(TestCase):
def test_thread_diff(self):
neko259
Fixed tag sync and tests
r1895 tag, created = Tag.objects.get_or_create_with_alias(name='test_tag')
neko259
Split tests module into separate modules
r821 opening_post = Post.objects.create_post(title='title', text='text',
tags=[tag])
neko259
Refactored websockets notifications and updating threads when updating posts
r1088 req = MockRequest()
neko259
Don't show reply link in the tree view. Fixed thread diff test after the thread id parameter was moved to POST dict.
r1196 req.POST['thread'] = opening_post.id
neko259
Added index on post. Update post uids when the thread reaches bumplimit
r1120 req.POST['uids'] = opening_post.uid
neko259
Split tests module into separate modules
r821 # Check the exact timestamp post was added
neko259
Refactored websockets notifications and updating threads when updating posts
r1088 empty_response = api.api_get_threaddiff(req)
neko259
Split tests module into separate modules
r821 diff = simplejson.loads(empty_response.content)
self.assertEqual(0, len(diff['updated']),
'There must be no updated posts in the diff.')
neko259
Added index on post. Update post uids when the thread reaches bumplimit
r1120 uids = [opening_post.uid]
neko259
Split tests module into separate modules
r821 reply = Post.objects.create_post(title='',
text='[post]%d[/post]\ntext' % opening_post.id,
neko259
Allow connecting post to many threads
r979 thread=opening_post.get_thread())
neko259
Refactored websockets notifications and updating threads when updating posts
r1088 req = MockRequest()
neko259
Don't show reply link in the tree view. Fixed thread diff test after the thread id parameter was moved to POST dict.
r1196 req.POST['thread'] = opening_post.id
neko259
Added index on post. Update post uids when the thread reaches bumplimit
r1120 req.POST['uids'] = ' '.join(uids)
neko259
Thread status field instead of bumpable and archived fields (per BB-73)
r1414 req.user = None
neko259
Split tests module into separate modules
r821 # Check the timestamp before post was added
neko259
Refactored websockets notifications and updating threads when updating posts
r1088 response = api.api_get_threaddiff(req)
neko259
Split tests module into separate modules
r821 diff = simplejson.loads(response.content)
neko259
Added index on post. Update post uids when the thread reaches bumplimit
r1120 self.assertEqual(2, len(diff['updated']),
'There must be 2 updated posts in the diff.')
neko259
Split tests module into separate modules
r821
neko259
Fixed thread diff test
r1173 # Reload post to get the new UID
opening_post = Post.objects.get(id=opening_post.id)
neko259
Refactored websockets notifications and updating threads when updating posts
r1088 req = MockRequest()
neko259
Don't show reply link in the tree view. Fixed thread diff test after the thread id parameter was moved to POST dict.
r1196 req.POST['thread'] = opening_post.id
neko259
Fixed thread diff test
r1173 req.POST['uids'] = ' '.join([opening_post.uid, reply.uid])
neko259
Refactored websockets notifications and updating threads when updating posts
r1088 empty_response = api.api_get_threaddiff(req)
neko259
Split tests module into separate modules
r821 diff = simplejson.loads(empty_response.content)
self.assertEqual(0, len(diff['updated']),
neko259
Added test for threads list API
r978 'There must be no updated posts in the diff.')
def test_get_threads(self):
# Create 10 threads
neko259
Fixed tag sync and tests
r1895 tag, created = Tag.objects.get_or_create_with_alias(name='test_tag')
neko259
Added test for threads list API
r978 for i in range(5):
Post.objects.create_post(title='title', text='text', tags=[tag])
# Get all threads
response = api.api_get_threads(MockRequest(), 5)
diff = simplejson.loads(response.content)
self.assertEqual(5, len(diff), 'Invalid thread list response.')
# Get less threads then exist
response = api.api_get_threads(MockRequest(), 3)
diff = simplejson.loads(response.content)
self.assertEqual(3, len(diff), 'Invalid thread list response.')
# Get more threads then exist
response = api.api_get_threads(MockRequest(), 10)
diff = simplejson.loads(response.content)
self.assertEqual(5, len(diff), 'Invalid thread list response.')