Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/units/model/context.py
blob: b48db6f2d6bff142a9f1f45c9bf57808bb718730 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
# sugar-lint: disable

from os.path import exists

from __init__ import tests

from sugar_network.node import obs
from sugar_network.client import IPCConnection
from sugar_network.toolkit import coroutine, enforce


class ContextTest(tests.Test):

    def test_SetCommonLayerForPackages(self):
        self.start_online_client()
        ipc = IPCConnection()

        guid = ipc.post(['context'], {
            'type': 'package',
            'title': 'title',
            'summary': 'summary',
            'description': 'description',
            })
        self.assertEqual(['common'], ipc.get(['context', guid, 'layer']))

        guid = ipc.post(['context'], {
            'type': 'package',
            'title': 'title',
            'summary': 'summary',
            'description': 'description',
            'layer': 'foo',
            })
        self.assertEqual(['foo', 'common'], ipc.get(['context', guid, 'layer']))

        guid = ipc.post(['context'], {
            'type': 'package',
            'title': 'title',
            'summary': 'summary',
            'description': 'description',
            'layer': ['common', 'bar'],
            })
        self.assertEqual(['common', 'bar'], ipc.get(['context', guid, 'layer']))

    def test_DefaultImages(self):
        self.start_online_client()
        ipc = IPCConnection()

        guid = ipc.post(['context'], {
            'guid': 'guid',
            'type': 'activity',
            'title': 'title',
            'summary': 'summary',
            'description': 'description',
            })
        assert exists('master/context/gu/guid/artifact_icon.blob')
        assert exists('master/context/gu/guid/icon.blob')
        assert exists('master/context/gu/guid/preview.blob')


if __name__ == '__main__':
    tests.main()