Esempio n. 1
0
    def test_callable_render(self):
        root = Node()
        root.node('item', 1)

        actual = str(root())
        self.assertIn("root", actual)
        self.assertIn("item", actual)
Esempio n. 2
0
    def test_callable_render(self):
        root = Node()
        root.node('item', 1)

        actual = str(root())
        self.assertIn("root", actual)
        self.assertIn("item", actual)
Esempio n. 3
0
    def test_nested(self):
        root = Node('one')
        root.node('item1', 1)
        with root.node('nested1') as nested:
            nested.node('nested2', 'two')

        self.assertEqual(root.__node_name__, 'one')
        self.assertEqual(root.__children__[0].__value__, 1)
        self.assertEqual(root.__children__[1].__children__[0].__value__, 'two')
Esempio n. 4
0
    def test_nested(self):
        root = Node('one')
        root.node('item1', 1)
        with root.node('nested1') as nested:
            nested.node('nested2', 'two')

        self.assertEqual(root.__node_name__, 'one')
        self.assertEqual(root.__children__[0].__value__, 1)
        self.assertEqual(root.__children__[1].__children__[0].__value__, 'two')
Esempio n. 5
0
    def test_add_duplicate_nodes(self):
        root = Node()
        root.node('greeting', 'Hello')
        root.node('greeting', 'Hi')

        hello = root.__children__[0]
        hi = root.__children__[1]

        self.assertEqual(hello.__value__, 'Hello')
        self.assertEqual(hi.__value__, 'Hi')
        for child in root.__children__:
            self.assertEqual(child.__node_name__, 'greeting')
Esempio n. 6
0
    def test_add_duplicate_nodes(self):
        root = Node()
        root.node('greeting', 'Hello')
        root.node('greeting', 'Hi')

        hello = root.__children__[0]
        hi = root.__children__[1]

        self.assertEqual(hello.__value__, 'Hello')
        self.assertEqual(hi.__value__, 'Hi')
        for child in root.__children__:
            self.assertEqual(child.__node_name__, 'greeting')