Exemple #1
0
    def test_property_raw_namespace(self):
        obj = Any()
        self.assertEqual(NamespaceType.ANY.value, obj.raw_namespace)

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

        obj = Any(namespace="    foo  \n    \t  \r  bar foo ")
        self.assertEqual("foo bar", obj.raw_namespace)
Exemple #2
0
    def test_end_open_content(self):
        open_content = OpenContent()
        open_content.any = Any()

        self.parser.end_open_content(open_content)
        self.assertEqual(0, open_content.any.index)

        open_content.mode = Mode.SUFFIX
        self.parser.end_open_content(open_content)
        self.assertEqual(sys.maxsize, open_content.any.index)

        obj = All(any=Any())
        self.parser.end_open_content(obj)
        self.assertEqual(0, obj.any.index)
Exemple #3
0
    def test_property_real_name(self):
        obj = Any()
        self.assertEqual("any_element", obj.real_name)

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

        obj.namespace = None
        with self.assertRaises(SchemaValueError):
            obj.real_name
Exemple #4
0
    def test_end_open_content(self):
        open_content = OpenContent()
        open_content.any = Any()
        element = etree.Element("uno")

        self.parser.end_open_content(open_content, element)
        self.assertEqual(0, open_content.any.index)

        open_content.mode = Mode.SUFFIX
        self.parser.end_open_content(open_content, element)
        self.assertEqual(sys.maxsize, open_content.any.index)
Exemple #5
0
    def test_property_real_name(self):
        obj = Any()
        self.assertEqual("any_element", obj.real_name)

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

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

        obj.namespace = "http://foo http://bar"
        self.assertEqual("foo_bar_element", obj.real_name)
Exemple #6
0
    def test_end_default_open_content(self):
        default_open_content = DefaultOpenContent()
        default_open_content.any = Any()
        element = etree.Element("uno")

        self.parser.end_default_open_content(default_open_content, element)
        self.assertEqual(default_open_content,
                         self.parser.default_open_content)
        self.assertEqual(0, default_open_content.any.index)

        default_open_content.mode = Mode.SUFFIX
        self.parser.end_default_open_content(default_open_content, element)
        self.assertEqual(sys.maxsize, default_open_content.any.index)
Exemple #7
0
    def test_end_default_open_content(self):
        default_open_content = DefaultOpenContent()
        default_open_content.any = Any()

        self.parser.end_default_open_content(default_open_content)
        self.assertEqual(default_open_content, self.parser.default_open_content)
        self.assertEqual(0, default_open_content.any.index)

        default_open_content.mode = Mode.SUFFIX
        self.parser.end_default_open_content(default_open_content)
        self.assertEqual(sys.maxsize, default_open_content.any.index)

        obj = ComplexType()
        self.parser.end_default_open_content(obj)
        self.assertIsNone(obj.open_content)
Exemple #8
0
 def test_property_is_attribute(self):
     self.assertTrue(Any().is_attribute)
Exemple #9
0
 def test_get_restrictions(self):
     obj = Any(min_occurs=1, max_occurs=2)
     self.assertEqual({
         "max_occurs": 2,
         "min_occurs": 1
     }, obj.get_restrictions())
Exemple #10
0
 def test_property_real_type(self):
     obj = Any(ns_map={"xs": Namespace.XS.uri})
     self.assertEqual("xs:object", obj.real_type)
Exemple #11
0
 def test_property_attr_types(self):
     obj = Any()
     obj.ns_map["xs"] = Namespace.XS.uri
     self.assertEqual(["xs:anyType"], list(obj.attr_types))
Exemple #12
0
 def test_property_real_type(self):
     obj = Any()
     obj.ns_map["xs"] = Namespace.XS.uri
     self.assertEqual("xs:anyType", obj.real_type)