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())
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)
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))
def test_is_attribute(self): obj = List() self.assertTrue(obj.is_attribute)
def test_get_restrictions(self): obj = List() self.assertEqual({"tokens": True}, obj.get_restrictions())
def test_real_type(self): obj = List() self.assertEqual("", obj.real_type) obj.item_type = "foo" self.assertEqual("foo", obj.real_type)
def test_real_name(self): obj = List() self.assertEqual("value", obj.real_name)
def test_get_restrictions(self): obj = List() expected = dict(min_occurs=0, max_occurs=sys.maxsize) self.assertEqual(expected, obj.get_restrictions())
def test_real_type(self): obj = List() self.assertEqual([], list(obj.attr_types)) obj.item_type = "foo" self.assertEqual(["foo"], list(obj.attr_types))