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

        obj.list = List()
        self.assertEqual({"tokens": True}, obj.get_restrictions())

        expected = dict(length=2)
        obj.restriction = Restriction(length=Length(value=2))
        self.assertEqual(expected, obj.get_restrictions())
Beispiel #2
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)
Beispiel #3
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))
Beispiel #4
0
 def test_is_attribute(self):
     obj = List()
     self.assertTrue(obj.is_attribute)
Beispiel #5
0
 def test_get_restrictions(self):
     obj = List()
     self.assertEqual({"tokens": True}, obj.get_restrictions())
Beispiel #6
0
    def test_real_type(self):
        obj = List()
        self.assertEqual("", obj.real_type)

        obj.item_type = "foo"
        self.assertEqual("foo", obj.real_type)
Beispiel #7
0
 def test_real_name(self):
     obj = List()
     self.assertEqual("value", obj.real_name)
Beispiel #8
0
 def test_get_restrictions(self):
     obj = List()
     expected = dict(min_occurs=0, max_occurs=sys.maxsize)
     self.assertEqual(expected, obj.get_restrictions())
Beispiel #9
0
    def test_real_type(self):
        obj = List()
        self.assertEqual([], list(obj.attr_types))

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