diff options
Diffstat (limited to 'tests/units/model/post.py')
-rwxr-xr-x | tests/units/model/post.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/units/model/post.py b/tests/units/model/post.py new file mode 100755 index 0000000..91a0298 --- /dev/null +++ b/tests/units/model/post.py @@ -0,0 +1,46 @@ +#!/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.post import Post +from sugar_network.model.release import Release +from sugar_network.toolkit import http + + +class PostTest(tests.Test): + + def test_SetContext(self): + volume = self.start_master([User, Context, Release, Post]) + client = Connection(auth=http.SugarAuth(keyfile.value)) + + self.assertRaises(http.NotFound, client.post, ['post'], {'type': 'comment', 'title': '', 'message': '', 'topic': 'absent'}) + + context = client.post(['context'], { + 'type': 'package', + 'title': 'title', + 'summary': 'summary', + 'description': 'description', + }) + topic = client.post(['post'], { + 'context': context, + 'title': 'title', + 'message': 'message', + 'type': 'update', + }) + comment = client.post(['post'], { + 'topic': topic, + 'title': 'title', + 'message': 'message', + 'type': 'comment', + }) + self.assertEqual( + context, + client.get(['post', comment, 'context'])) + + +if __name__ == '__main__': + tests.main() |