Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/units/model/post.py
blob: 91a02982eced1d77322421a1d2751946d1415cc5 (plain)
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
#!/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()