Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
10df18a9
Commit
10df18a9
authored
9 months ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
TST: added test for generating children using xpath in the xml converter
parent
072bffdb
No related branches found
No related tags found
2 merge requests
!181
Release 0.9.0
,
!174
XML Converter
Pipeline
#54373
failed
9 months ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_xml_converter.py
+26
-4
26 additions, 4 deletions
unittests/test_xml_converter.py
with
26 additions
and
4 deletions
unittests/test_xml_converter.py
+
26
−
4
View file @
10df18a9
...
...
@@ -101,6 +101,28 @@ subtree:
src: test2
"""
),
"
TestXMLTagConverter
"
,
converter_registry
)
@pytest.fixture
def
basic_xpath_xmltag_converter
(
converter_registry
):
return
XMLTagConverter
(
yaml
.
safe_load
(
"""
type: XMLTag
match_tag: a
match_attrib: # default is the empty dictionary
"
(?P<ref>(href|url))
"
:
"
test(?P<number>[0-9])
"
# either the
"
href
"
or the
"
url
"
attribute must be set
alt: (.+) # this attribute must be present and contain at least one character
match_text:
\\
s*(?P<node_text>.+)
\\
s*
xpath: child::*/*
subtree:
img:
type: XMLTag
match_name: img
match_attrib:
src: test2
testnode:
type: XMLTag
match_name: testnode
"""
),
"
TestXMLTagConverter
"
,
converter_registry
)
def
test_simple_xml
(
basic_xmltag_converter
):
...
...
@@ -167,7 +189,7 @@ def test_not_matching(basic_xmltag_converter):
# TODO: how to match " ajskdlfjaldsf ajsdklfjadkl " without the whitespaces in regexp correctly?
def
test_nested_simple_xml
(
basic_xmltag_converter
):
def
test_nested_simple_xml
(
basic_xmltag_converter
,
basic_xpath_xmltag_converter
):
"""
Test for xml conversion including children.
"""
...
...
@@ -198,13 +220,13 @@ def test_nested_simple_xml(basic_xmltag_converter):
"""
tag
=
XMLTagElement
(
fromstring
(
xml_text
))
m
=
basic_xmltag_converter
.
match
(
tag
)
m
=
basic_
xpath_
xmltag_converter
.
match
(
tag
)
assert
m
is
not
None
general_store
=
GeneralStore
()
children
=
basic_xmltag_converter
.
create_children
(
general_store
,
tag
)
children
=
basic_
xpath_
xmltag_converter
.
create_children
(
general_store
,
tag
)
assert
len
(
children
)
==
1
assert
isinstance
(
children
[
0
],
XMLTagElement
)
assert
children
[
0
].
name
==
"
img
"
assert
children
[
0
].
name
==
"
img
/testnode
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment