##// END OF EJS Templates
Fixed issues in sync test
neko259 -
r1503:135b5a86 decentral
parent child Browse files
Show More
@@ -15,7 +15,7 b' class SyncTest(TestCase):'
15 Forms a GET request of a post and checks the response.
15 Forms a GET request of a post and checks the response.
16 """
16 """
17
17
18 KeyPair.objects.generate_key(primary=True)
18 key = KeyPair.objects.generate_key(primary=True)
19 tag = Tag.objects.create(name='tag1')
19 tag = Tag.objects.create(name='tag1')
20 post = Post.objects.create_post(title='test_title', text='test_text',
20 post = Post.objects.create_post(title='test_title', text='test_text',
21 tags=[tag])
21 tags=[tag])
@@ -44,16 +44,19 b' class SyncTest(TestCase):'
44 '<pub-time>%s</pub-time>'
44 '<pub-time>%s</pub-time>'
45 '</content>' % (
45 '</content>' % (
46 post.global_id.key,
46 post.global_id.key,
47 post.id,
47 post.global_id.local_id,
48 post.global_id.key_type,
48 post.global_id.key_type,
49 post.title,
49 post.title,
50 post.get_raw_text(),
50 post.get_raw_text(),
51 post.get_thread().get_tags().first().name,
51 post.get_thread().get_tags().first().name,
52 post.get_pub_time_str(),
52 post.get_pub_time_str(),
53 ) in response_get(request).content.decode(),
53 ) in response,
54 'Wrong response generated for the GET request.')
54 'Wrong response generated for the GET request.')
55
55
56 post.delete()
56 post.delete()
57 key.delete()
58
59 KeyPair.objects.generate_key(primary=True)
57
60
58 SyncManager.parse_response_get(response)
61 SyncManager.parse_response_get(response)
59 self.assertEqual(1, Post.objects.count(),
62 self.assertEqual(1, Post.objects.count(),
@@ -70,3 +73,29 b' class SyncTest(TestCase):'
70
73
71 self.assertEqual(1, parsed_post.global_id.signature_set.count(),
74 self.assertEqual(1, parsed_post.global_id.signature_set.count(),
72 'Signature was not saved.')
75 'Signature was not saved.')
76
77 post = parsed_post
78
79 # Trying to sync the same once more
80 response = response_get(request).content.decode()
81
82 self.assertTrue(
83 '<status>success</status>'
84 '<models>'
85 '<model name="post">'
86 '<content>'
87 '<id key="%s" local-id="%d" type="%s" />'
88 '<title>%s</title>'
89 '<text>%s</text>'
90 '<tags><tag>%s</tag></tags>'
91 '<pub-time>%s</pub-time>'
92 '</content>' % (
93 post.global_id.key,
94 post.global_id.local_id,
95 post.global_id.key_type,
96 post.title,
97 post.get_raw_text(),
98 post.get_thread().get_tags().first().name,
99 post.get_pub_time_str(),
100 ) in response,
101 'Wrong response generated for the GET request.')
General Comments 0
You need to be logged in to leave comments. Login now