##// 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:

r837:fbeaaa16 decentral
r837:fbeaaa16 decentral
Show More
test_sync.py
49 lines | 1.5 KiB | text/x-python | PythonLexer
from boards.models import KeyPair, Post
from boards.tests.mocks import MockRequest
from boards.views.sync import respond_get
__author__ = 'neko259'
from django.test import TestCase
class SyncTest(TestCase):
def test_get(self):
"""
Forms a GET request of a post and checks the response.
"""
KeyPair.objects.generate_key(primary=True)
post = Post.objects.create_post(title='test_title', text='test_text')
request = MockRequest()
request.POST['xml'] = (
'<request type="get" version="1.0">'
'<model name="post" version="1.0">'
'<id key="%s" local-id="%d" type="%s" />'
'</model>'
'</request>' % (post.global_id.key,
post.id,
post.global_id.key_type)
)
self.assertTrue(
'<status>success</status>'
'<models>'
'<model name="post" ref-id="1">'
'<id key="%s" local-id="%d" type="%s" />'
'<title>%s</title>'
'<text>%s</text>'
'<pub-time>%d</pub-time>'
'<edit-time>%d</edit-time>'
'</model>'
'</models>' % (
post.global_id.key,
post.id,
post.global_id.key_type,
post.title,
post.text.raw,
post.get_pub_time_epoch(),
post.get_edit_time_epoch(),
) in respond_get(request).content.decode(),
'Wrong response generated for the GET request.')