File: jsonparser_tests.py

package info (click to toggle)
python-reconfigure 0.1.81%2Bgit20171214.2b8729a8-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 724 kB
  • sloc: python: 4,219; makefile: 186; sh: 7
file content (31 lines) | stat: -rw-r--r-- 737 bytes parent folder | download | duplicates (3)
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
import json
from reconfigure.tests.parsers.base_test import BaseParserTest
from reconfigure.parsers import JsonParser
from reconfigure.nodes import *


class JsonParserTest (BaseParserTest):
    parser = JsonParser()
    source = """{
    "p2": 123,
    "s1": {
        "s1p1": "qwerty"
    }
}
"""

    parsed = RootNode(None,
        PropertyNode('p2',  123),
        Node('s1',
            PropertyNode('s1p1',  'qwerty'),
        ),
    )

    def test_stringify(self):
        unparsed = self.parser.stringify(self.__class__.parsed)
        a, b = self.stringified, unparsed
        if json.loads(a) != json.loads(b):
            print('SOURCE: %s\n\nGENERATED: %s' % (a, b))
            self.assertEquals(a, b)

del BaseParserTest