Esempio n. 1
0
    def test_get_restrictions(self):
        obj = SimpleType()
        self.assertEqual({}, obj.get_restrictions())

        expected = dict(length=2)
        obj.restriction = Restriction(length=Length(value=2))
        self.assertEqual(expected, obj.get_restrictions())
Esempio n. 2
0
    def test_property_is_enumeration(self):
        obj = SimpleType()
        self.assertFalse(obj.is_enumeration)

        obj.restriction = Restriction()
        self.assertFalse(obj.is_enumeration)

        obj.restriction.enumerations.append(Enumeration())
        self.assertTrue(obj.is_enumeration)
Esempio n. 3
0
    def test_property_real_type(self):
        obj = SimpleType()
        self.assertIsNone(obj.real_type)

        obj.union = Union(member_types="thug")
        self.assertEqual("thug", obj.real_type)

        obj.list = List(item_type="foo")
        self.assertEqual("foo", obj.real_type)

        obj.restriction = Restriction(base="bar")
        self.assertEqual("bar", obj.real_type)

        obj = SimpleType(restriction=Restriction())
        obj.restriction.enumerations.append(Enumeration())
        self.assertIsNone(obj.real_type)
Esempio n. 4
0
    def test_property_attr_types(self):
        obj = SimpleType()
        self.assertEqual([], list(obj.attr_types))

        obj.union = Union(member_types="thug")
        self.assertEqual(["thug"], list(obj.attr_types))

        obj.list = List(item_type="foo")
        self.assertEqual(["foo"], list(obj.attr_types))

        obj.restriction = Restriction(base="bar")
        self.assertEqual(["bar"], list(obj.attr_types))

        obj = SimpleType(restriction=Restriction())
        obj.restriction.enumerations.append(Enumeration())
        self.assertEqual([], list(obj.attr_types))