File: test_definitions.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 (35 lines) | stat: -rw-r--r-- 1,282 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
from unittest import TestCase

from tests import fixtures_dir
from xsdata.codegen.parsers import DefinitionsParser
from xsdata.models.wsdl import Definitions, Import


class DefinitionsParserTests(TestCase):
    def setUp(self):
        self.parser = DefinitionsParser()
        super().setUp()

    def test_complete(self):
        path = fixtures_dir.joinpath("calculator/services.wsdl").resolve()
        parser = DefinitionsParser(location="here.wsdl")
        definitions = parser.from_path(path, Definitions)

        self.assertIsInstance(definitions, Definitions)
        self.assertEqual(1, len(definitions.services))
        self.assertEqual(2, len(definitions.bindings))
        self.assertEqual(1, len(definitions.port_types))
        self.assertEqual(1, len(definitions.types.schemas))
        self.assertEqual(8, len(definitions.messages))
        self.assertEqual(parser.location, definitions.bindings[0].location)

    def test_end_import(self):
        parser = DefinitionsParser(location="foo/bar.wsdl")
        imp = Import(location="../hello/foo.wsdl")

        parser.end_import(imp)
        self.assertEqual("hello/foo.wsdl", imp.location)

        parser.location = None
        parser.end_import(imp)
        self.assertEqual("hello/foo.wsdl", imp.location)