aboutsummaryrefslogtreecommitdiff
path: root/tests/test_objects.py
blob: 48dfaf10787e5b8a60c243ccdbd3131bb242de70 (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
import unittest

from pyapd import objects


class TestAPObjects(unittest.TestCase):

    def test_activity_from_json(self):
        act = objects.APObject.from_jsons('''{
            "id": "http://example.org/123456",
            "type": "object"
            }''')
        self.assertIsInstance(act, objects.APObject)
        self.assertEqual(act.ap_id, 'http://example.org/123456')
        self.assertEqual(act.ap_type, 'object')

    def test_activity_to_json(self):
        act = objects.APObject(
            ap_id="http://example.org/123456",
            ap_type="object",
            )
        data = act.to_jsons()
        self.assertIsInstance(data, str)
        self.assertIn('"id": "http://example.org/123456"', data)