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'] = ( '' '' '' '' '' % (post.global_id.key, post.id, post.global_id.key_type) ) self.assertTrue( 'success' '' '' '' '' '%s' '%s' '%d' '' % ( post.global_id.key, post.id, post.global_id.key_type, post.title, post.get_raw_text(), post.get_pub_time_epoch(), ) in respond_get(request).content.decode(), 'Wrong response generated for the GET request.')