Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
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-advanced-user-tools
Commits
d2312596
Commit
d2312596
authored
4 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Remove TransactionBenchmark from hased xml
parent
ff6da0ca
No related branches found
No related tags found
1 merge request
!22
Release 0.3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/cache.py
+15
-4
15 additions, 4 deletions
src/caosadvancedtools/cache.py
unittests/test_cache.py
+18
-2
18 additions, 2 deletions
unittests/test_cache.py
with
33 additions
and
6 deletions
src/caosadvancedtools/cache.py
+
15
−
4
View file @
d2312596
...
...
@@ -29,9 +29,8 @@ import os
import
sqlite3
from
hashlib
import
sha256
from
lxml
import
etree
import
caosdb
as
db
from
lxml
import
etree
def
put_in_container
(
stuff
):
...
...
@@ -44,11 +43,23 @@ def put_in_container(stuff):
return
stuff
def
cleanXML
(
xml
):
# remove transaction benchmark
props
=
xml
.
findall
(
'
TransactionBenchmark
'
)
for
prop
in
props
:
parent
=
prop
.
find
(
"
..
"
)
parent
.
remove
(
prop
)
return
xml
def
get_pretty_xml
(
cont
):
cont
=
put_in_container
(
cont
)
xml
=
cont
.
to_xml
(
local_serialization
=
True
)
cleanXML
(
xml
)
return
etree
.
tounicode
(
cont
.
to_xml
(
local_serialization
=
True
),
pretty_print
=
True
)
return
etree
.
tounicode
(
xml
,
pretty_print
=
True
)
class
Cache
(
object
):
...
...
This diff is collapsed.
Click to expand it.
unittests/test_cache.py
+
18
−
2
View file @
d2312596
...
...
@@ -26,8 +26,8 @@ from copy import deepcopy
from
tempfile
import
NamedTemporaryFile
import
caosdb
as
db
from
caosadvancedtools.cache
import
Cach
e
from
caosadvancedtools.cache
import
Cache
,
cleanXML
from
lxml
import
etre
e
class
CacheTest
(
unittest
.
TestCase
):
...
...
@@ -75,3 +75,19 @@ class CacheTest(unittest.TestCase):
self
.
cache
.
insert_list
(
hashes
,
entities
)
self
.
assertEqual
(
self
.
cache
.
check_existing
(
hashes
[
0
]),
1001
)
self
.
assertEqual
(
self
.
cache
.
check_existing
(
hashes
[
2
]),
1003
)
def
test_clean
(
self
):
xml
=
etree
.
XML
(
"""
\
<Entities>
<TransactionBenchmark>
</TransactionBenchmark>
<RecordType id=
"
110
"
name=
"
Guitar
"
>
<Version id=
"
eb8c7527980e598b887e84d055db18cfc3806ce6
"
head=
"
true
"
/>
<Parent id=
"
108
"
name=
"
MusicalInstrument
"
flag=
"
inheritance:OBLIGATORY,
"
/>
<Property id=
"
106
"
name=
"
electric
"
datatype=
"
BOOLEAN
"
importance=
"
RECOMMENDED
"
flag=
"
inheritance:FIX
"
/>
</RecordType>
</Entities>
"""
)
cleanXML
(
xml
)
assert
len
(
xml
.
findall
(
'
TransactionBenchmark
'
))
==
0
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