Пример #1
0
    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())
Пример #2
0
    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())