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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
072bffdb
Commit
072bffdb
authored
10 months ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: refactored test fixtures
parent
3bb7861a
No related branches found
No related tags found
2 merge requests
!181
Release 0.9.0
,
!174
XML Converter
Pipeline
#54372
failed
10 months ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_xml_converter.py
+23
-24
23 additions, 24 deletions
unittests/test_xml_converter.py
with
23 additions
and
24 deletions
unittests/test_xml_converter.py
+
23
−
24
View file @
072bffdb
...
@@ -84,8 +84,8 @@ def converter_registry():
...
@@ -84,8 +84,8 @@ def converter_registry():
@pytest.fixture
@pytest.fixture
def
basic_
cfood
(
):
def
basic_
xmltag_converter
(
converter_registry
):
xml_cfood
=
yaml
.
safe_load
(
"""
return
XMLTagConverter
(
yaml
.
safe_load
(
"""
type: XMLTag
type: XMLTag
match_tag: a
match_tag: a
match_attrib: # default is the empty dictionary
match_attrib: # default is the empty dictionary
...
@@ -93,33 +93,13 @@ match_attrib: # default is the empty dictionary
...
@@ -93,33 +93,13 @@ match_attrib: # default is the empty dictionary
alt: (.+) # this attribute must be present and contain at least one character
alt: (.+) # this attribute must be present and contain at least one character
match_text:
\\
s*(?P<node_text>.+)
\\
s*
match_text:
\\
s*(?P<node_text>.+)
\\
s*
# _*_ marks the default:
attribs_as_children: true # true / _false_
text_as_children: true # true / _false_
tags_as_children: true # _true_ / false
subtree:
subtree:
text: # this would be created by the text_as_children-flag
type: XMLTextNode
match: test
alt: # this would be created by the attribs_as_children-flag
type: TextElement
match_name: alt
match_value: ^(?P<text>.*)$
img:
img:
type: XMLTag
type: XMLTag
match_name: img
match_name: img
match_attrib:
match_attrib:
src: test2
src: test2
"""
)
"""
),
"
TestXMLTagConverter
"
,
converter_registry
)
return
xml_cfood
@pytest.fixture
def
basic_xmltag_converter
(
basic_cfood
,
converter_registry
):
converter
=
XMLTagConverter
(
basic_cfood
,
"
TestXMLTagConverter
"
,
converter_registry
)
return
converter
...
@@ -187,7 +167,6 @@ def test_not_matching(basic_xmltag_converter):
...
@@ -187,7 +167,6 @@ def test_not_matching(basic_xmltag_converter):
# TODO: how to match " ajskdlfjaldsf ajsdklfjadkl " without the whitespaces in regexp correctly?
# 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
):
"""
"""
Test for xml conversion including children.
Test for xml conversion including children.
...
@@ -203,9 +182,29 @@ def test_nested_simple_xml(basic_xmltag_converter):
...
@@ -203,9 +182,29 @@ def test_nested_simple_xml(basic_xmltag_converter):
assert
m
is
not
None
assert
m
is
not
None
general_store
=
GeneralStore
()
general_store
=
GeneralStore
()
children
=
basic_xmltag_converter
.
create_children
(
general_store
,
tag
)
assert
len
(
children
)
==
1
assert
isinstance
(
children
[
0
],
XMLTagElement
)
assert
children
[
0
].
name
==
"
img
"
xml_text
=
"""
<a href=
"
test1
"
alt=
"
no link
"
>
test <img src=
"
test2
"
>
<testnode/> </img>
</a>
"""
tag
=
XMLTagElement
(
fromstring
(
xml_text
))
m
=
basic_xmltag_converter
.
match
(
tag
)
assert
m
is
not
None
general_store
=
GeneralStore
()
children
=
basic_xmltag_converter
.
create_children
(
general_store
,
tag
)
children
=
basic_xmltag_converter
.
create_children
(
general_store
,
tag
)
assert
len
(
children
)
==
1
assert
len
(
children
)
==
1
assert
isinstance
(
children
[
0
],
XMLTagElement
)
assert
isinstance
(
children
[
0
],
XMLTagElement
)
assert
children
[
0
].
name
==
"
img
"
assert
children
[
0
].
name
==
"
img
"
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