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
c8c3fd5d
Commit
c8c3fd5d
authored
2 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
TST: Add xfailing test for overwrite-on-update bug
parent
99593155
No related branches found
No related tags found
2 merge requests
!71
REL: RElease v0.2.0
,
!60
F upate overwrite
Pipeline
#29609
passed
2 years 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
integrationtests/test_issues.py
+86
-2
86 additions, 2 deletions
integrationtests/test_issues.py
with
86 additions
and
2 deletions
integrationtests/test_issues.py
+
86
−
2
View file @
c8c3fd5d
...
...
@@ -16,23 +16,29 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from
pytest
import
fixture
from
pytest
import
fixture
,
mark
import
caosdb
as
db
from
caoscrawler.crawl
import
Crawler
from
caoscrawler.identifiable_adapters
import
CaosDBIdentifiableAdapter
from
caoscrawler.structure_elements
import
Dict
@fixture
def
clear_database
():
db
.
execute_query
(
"
FIND ENTITY
"
).
delete
(
raise_exception_on_error
=
False
)
@mark.xfail
(
reason
=
"
See issue https://gitlab.com/caosdb/caosdb-crawler/-/issues/23
"
)
def
test_issue_23
(
clear_database
):
"""
Test that an update leaves existing properties, that were not found by
the crawler, unchanged.
"""
# insert a simplistic model
# insert a simplistic model an arecord of type TestType with identifying
# property and prop_a, but not prop_b.
prop_ident
=
db
.
Property
(
name
=
"
identifying_prop
"
,
datatype
=
db
.
TEXT
)
prop_a
=
db
.
Property
(
name
=
"
prop_a
"
,
datatype
=
db
.
TEXT
)
prop_b
=
db
.
Property
(
name
=
"
prop_b
"
,
datatype
=
db
.
TEXT
)
...
...
@@ -41,3 +47,81 @@ def test_issue_23(clear_database):
rec
.
add_property
(
name
=
"
identifying_prop
"
,
value
=
"
identifier
"
)
rec
.
add_property
(
name
=
"
prop_a
"
,
value
=
"
something
"
)
db
.
Container
().
extend
([
prop_ident
,
prop_a
,
prop_b
,
rt
,
rec
]).
insert
()
# set up crawler, first cfood defining a TestType record with
# identifying_prop and prop_b, but not prop_a ...
crawler_definition
=
{
"
DictTest
"
:
{
"
type
"
:
"
Dict
"
,
"
match
"
:
"
(.*)
"
,
"
records
"
:
{
"
TestType
"
:
{}
},
"
subtree
"
:
{
"
identifying_element
"
:
{
"
type
"
:
"
DictTextElement
"
,
"
match_name
"
:
"
ident
"
,
"
match_value
"
:
"
(?P<ident_value>.*)
"
,
"
records
"
:
{
"
TestType
"
:
{
"
identifying_prop
"
:
"
$ident_value
"
}
}
},
"
other_element
"
:
{
"
type
"
:
"
DictTextElement
"
,
"
match_name
"
:
"
prop_b
"
,
"
match_value
"
:
"
(?P<other_value>.*)
"
,
"
records
"
:
{
"
TestType
"
:
{
"
prop_b
"
:
"
$other_value
"
}
}
}
}
}
}
# register identifiable for TestType
ident
=
CaosDBIdentifiableAdapter
()
ident
.
register_identifiable
(
"
TestType
"
,
db
.
RecordType
().
add_parent
(
name
=
"
TestType
"
).
add_property
(
name
=
"
identifying_prop
"
))
crawler
=
Crawler
(
debug
=
True
,
identifiableAdapter
=
ident
)
converter_registry
=
crawler
.
load_converters
(
crawler_definition
)
# the dictionary to be crawled...
test_dict
=
{
"
ident
"
:
"
identifier
"
,
"
prop_b
"
:
"
something_else
"
}
records
=
crawler
.
start_crawling
(
Dict
(
"
TestDict
"
,
test_dict
),
crawler_definition
,
converter_registry
)
assert
len
(
records
)
==
1
rec_crawled
=
records
[
0
]
assert
rec_crawled
.
parents
[
0
].
name
==
"
TestType
"
assert
rec_crawled
.
get_property
(
"
identifying_prop
"
)
is
not
None
assert
rec_crawled
.
get_property
(
"
identifying_prop
"
).
value
==
"
identifier
"
assert
rec_crawled
.
get_property
(
"
prop_b
"
)
is
not
None
assert
rec_crawled
.
get_property
(
"
prop_b
"
).
value
==
"
something_else
"
# no interaction with the database yet, so the rrecord shouldn't have a prop_a yet
assert
rec_crawled
.
get_property
(
"
prop_a
"
)
is
None
# synchronize with database and update the record
ins
,
ups
=
crawler
.
synchronize
()
assert
len
(
ins
)
==
0
assert
len
(
ups
)
==
1
# retrieve and check that name and properties have been combined correctly
rec_retrieved
=
db
.
Record
(
id
=
rec
.
id
).
retrieve
()
assert
rec_retrieved
.
name
==
rec
.
name
assert
rec_retrieved
.
get_property
(
"
identifying_prop
"
).
value
==
rec
.
get_property
(
"
identifying_prop
"
).
value
assert
rec_retrieved
.
get_property
(
"
prop_a
"
).
value
==
rec
.
get_property
(
"
prop_a
"
).
value
assert
rec_retrieved
.
get_property
(
"
identifying_prop
"
).
value
==
rec_crawled
.
get_property
(
"
identifying_prop
"
).
value
assert
rec_retrieved
.
get_property
(
"
prop_b
"
).
value
==
rec_crawled
.
get_property
(
"
prop_b
"
).
value
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