File: test_any_attribute.py

package info (click to toggle)
python-xsdata 24.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,936 kB
  • sloc: python: 29,257; xml: 404; makefile: 27; sh: 6
file content (42 lines) | stat: -rw-r--r-- 1,380 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from unittest import TestCase

from xsdata.models.enums import Namespace, NamespaceType
from xsdata.models.xsd import AnyAttribute


class AnyAttributeTests(TestCase):
    def test_is_attribute(self):
        obj = AnyAttribute()
        self.assertTrue(obj.is_property)

    def test_property_raw_namespace(self):
        obj = AnyAttribute()
        self.assertEqual(NamespaceType.ANY_NS, obj.raw_namespace)

        obj.namespace = "foo"
        self.assertEqual("foo", obj.raw_namespace)

        obj = AnyAttribute(namespace="    foo  \n    \t  \r  bar foo ")
        self.assertEqual("foo bar", obj.raw_namespace)

    def test_property_real_name(self):
        obj = AnyAttribute()
        self.assertEqual("@any_attributes", obj.real_name)

        obj.namespace = "foo"
        self.assertEqual("@foo_attributes", obj.real_name)

        obj.namespace = "http://www.xsdata.com/somewhere.xsd"
        self.assertEqual("@xsdata_com/somewhere_attributes", obj.real_name)

        obj.namespace = "http://foo http://bar"
        self.assertEqual("@foo_bar_attributes", obj.real_name)

    def test_property_real_type(self):
        obj = AnyAttribute()
        obj.ns_map["xs"] = Namespace.XS.uri
        self.assertEqual(["xs:anyType"], list(obj.attr_types))

    def get_restrictions(self):
        obj = AnyAttribute()
        self.assertEqual({}, obj.get_restrictions())