예제 #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)
예제 #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)
예제 #3
0
파일: test_any.py 프로젝트: rmr1154/xsdata
    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
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #8
0
 def test_property_is_attribute(self):
     self.assertTrue(Any().is_attribute)
예제 #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())
예제 #10
0
 def test_property_real_type(self):
     obj = Any(ns_map={"xs": Namespace.XS.uri})
     self.assertEqual("xs:object", obj.real_type)
예제 #11
0
파일: test_any.py 프로젝트: gramm/xsdata
 def test_property_attr_types(self):
     obj = Any()
     obj.ns_map["xs"] = Namespace.XS.uri
     self.assertEqual(["xs:anyType"], list(obj.attr_types))
예제 #12
0
파일: test_any.py 프로젝트: igieon/xsdata
 def test_property_real_type(self):
     obj = Any()
     obj.ns_map["xs"] = Namespace.XS.uri
     self.assertEqual("xs:anyType", obj.real_type)