1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#!/usr/bin/env python
# sugar-lint: disable
from __init__ import tests
from sugar_network.client import Connection, keyfile
from sugar_network.model.user import User
from sugar_network.model.context import Context
from sugar_network.model.review import Review
from sugar_network.model.feedback import Feedback
from sugar_network.model.solution import Solution
from sugar_network.model.comment import Comment
from sugar_network.model.release import Release
from sugar_network.toolkit import http
class CommentTest(tests.Test):
def test_SetContext(self):
volume = self.start_master([User, Context, Review, Feedback, Solution, Comment, Release])
client = Connection(auth=http.SugarAuth(keyfile.value))
self.assertRaises(http.NotFound, client.post, ['comment'], {'message': '', 'review': 'absent'})
self.assertRaises(http.NotFound, client.post, ['comment'], {'message': '', 'feedback': 'absent'})
self.assertRaises(http.NotFound, client.post, ['comment'], {'message': '', 'solution': 'absent'})
context = client.post(['context'], {
'type': 'package',
'title': 'title',
'summary': 'summary',
'description': 'description',
})
review = client.post(['review'], {
'context': context,
'title': 'title',
'content': 'content',
'rating': 5,
})
comment = client.post(['comment'], {
'review': review,
'message': '',
})
self.assertEqual(
context,
client.get(['comment', comment, 'context']))
feedback = client.post(['feedback'], {
'context': context,
'type': 'idea',
'title': 'title',
'content': 'content',
})
comment = client.post(['comment'], {
'feedback': feedback,
'message': '',
})
self.assertEqual(
context,
client.get(['comment', comment, 'context']))
solution = client.post(['solution'], {
'feedback': feedback,
'content': 'content',
})
comment = client.post(['comment'], {
'solution': solution,
'message': '',
})
self.assertEqual(
context,
client.get(['comment', comment, 'context']))
if __name__ == '__main__':
tests.main()
|