def test_get_restrictions(self): self.assertEqual({}, Restriction().get_restrictions()) obj = Restriction( min_exclusive=MinExclusive(value=1), min_inclusive=MinInclusive(value=2), min_length=MinLength(value=3), max_exclusive=MaxExclusive(value=4), max_inclusive=MaxInclusive(value=5), max_length=MaxLength(value=6), total_digits=TotalDigits(value=7), fraction_digits=FractionDigits(value=8), length=Length(value=9), white_space=WhiteSpace(value="collapse"), patterns=[Pattern(value="[0-9]"), Pattern(value="[A-Z]")], enumerations=[Enumeration(value="str")], ) expected = { "fraction_digits": 8, "length": 9, "max_exclusive": 4, "max_inclusive": 5, "max_length": 6, "min_exclusive": 1, "min_inclusive": 2, "min_length": 3, "pattern": "[0-9]|[A-Z]", "total_digits": 7, "white_space": "collapse", } self.assertEqual(expected, obj.get_restrictions())
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())
def test_get_restrictions(self): obj = Attribute() self.assertEqual({}, obj.get_restrictions()) obj.use = UseType.REQUIRED expected = {"max_occurs": 1, "min_occurs": 1, "required": True} self.assertEqual(expected, obj.get_restrictions()) obj.simple_type = SimpleType(restriction=Restriction(length=Length(value=1))) expected.update(dict(length=1)) self.assertEqual(expected, obj.get_restrictions())
def test_get_restrictions(self): obj = Element(min_occurs=1, max_occurs=1) expected = {"min_occurs": 1, "max_occurs": 1} self.assertEqual(expected, obj.get_restrictions()) obj.simple_type = SimpleType(restriction=Restriction(length=Length( value=9))) expected.update({"length": 9}) self.assertEqual(expected, obj.get_restrictions()) obj.nillable = False self.assertEqual(expected, obj.get_restrictions()) obj.nillable = True expected.update({"nillable": True}) self.assertEqual(expected, obj.get_restrictions())
def test_get_restrictions(self): obj = Attribute() self.assertEqual({}, obj.get_restrictions()) obj.use = UseType.REQUIRED expected = {"required": True} self.assertEqual(expected, obj.get_restrictions()) obj.use = UseType.PROHIBITED expected = {"prohibited": True} self.assertEqual(expected, obj.get_restrictions()) obj.simple_type = SimpleType(restriction=Restriction(length=Length( value=1))) expected["length"] = 1 self.assertEqual(expected, obj.get_restrictions())
def test_get_restrictions(self): obj = Element(min_occurs=1, max_occurs=1) expected = {"min_occurs": 1, "max_occurs": 1} self.assertEqual(expected, obj.get_restrictions()) obj.simple_type = SimpleType(restriction=Restriction(length=Length(value=9))) expected["length"] = 9 self.assertEqual(expected, obj.get_restrictions()) obj.nillable = False self.assertEqual(expected, obj.get_restrictions()) obj.nillable = True expected["nillable"] = True self.assertEqual(expected, obj.get_restrictions()) obj.type = "NMTOKENS" expected["tokens"] = True self.assertEqual(expected, obj.get_restrictions())