summaryrefslogtreecommitdiffstats
path: root/app/tests/test_entry_schema.py
blob: f1e495aef32c35697b9a4c08ba93092f01c2afa0 (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
import unittest
from toscalib.types.property import PropertyDefinition
from toscalib.templates.database import ToscaDB


class TestEntrySchemaMethods(unittest.TestCase):

    def test_parse_content(self):
        content = {'type': 'list', 'entry_schema': {'type': 'integer'}}
        prop_def = PropertyDefinition('propName', content)
        self.assertFalse(prop_def.parsed)
        self.assertIsNone(prop_def.type)
        self.assertIsNone(prop_def.type_obj)
        prop_def._parse_content(ToscaDB)
        self.assertTrue(prop_def.parsed)
        self.assertEqual(prop_def.type, 'list')
        self.assertTrue(prop_def.type_obj.built_in)
        self.assertEqual(prop_def.type_obj.name, 'list')
        self.assertTrue(prop_def.type_obj.parsed)
        self.assertEqual(prop_def.type_obj.type, 'list')
        self.assertEqual(prop_def.type_obj.entry.type, 'integer')
        self.assertTrue(prop_def.type_obj.entry.parsed)
        self.assertTrue(prop_def.type_obj.entry.type_obj.built_in)
        self.assertEqual(prop_def.type_obj.entry.type_obj.name, 'integer')
        self.assertEqual(prop_def.type_obj.entry.type_obj.type, 'integer')