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
5a231f42
Commit
5a231f42
authored
3 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
TST: tests for the identified cache
parent
80a04464
No related branches found
No related tags found
1 merge request
!53
Release 0.1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_cache.py
+56
-0
56 additions, 0 deletions
unittests/test_cache.py
with
56 additions
and
0 deletions
unittests/test_cache.py
0 → 100644
+
56
−
0
View file @
5a231f42
#!/bin/python
# Tests for entity comparison
# A. Schlemmer, 06/2021
import
caosdb
as
db
from
pytest
import
raises
from
newcrawler.identified_cache
import
_create_hashable_string
as
create_hash_string
def
test_normal_hash_creation
():
# Test the initial functionality:
# hash comprises only one parent, name and properties:
r1
=
db
.
Record
()
r1
.
add_property
(
name
=
"
test
"
)
r1
.
add_parent
(
"
bla
"
)
hash1
=
create_hash_string
(
r1
)
r2
=
db
.
Record
()
r2
.
add_property
(
name
=
"
test2
"
)
r2
.
add_parent
(
"
bla
"
)
hash2
=
create_hash_string
(
r2
)
assert
hash1
!=
hash2
r3
=
db
.
Record
()
r3
.
add_property
(
name
=
"
test
"
)
r3
.
add_parent
(
"
bla bla
"
)
hash3
=
create_hash_string
(
r3
)
assert
hash1
!=
hash3
assert
hash2
!=
hash3
# no name and no properties and no parents:
r4
=
db
.
Record
()
with
raises
(
RuntimeError
,
match
=
"
.*1 parent.*
"
):
create_hash_string
(
r4
)
# should work
r4
.
add_parent
(
"
bla
"
)
assert
len
(
create_hash_string
(
r4
))
>
0
r4
.
add_property
(
name
=
"
test
"
)
assert
len
(
create_hash_string
(
r4
))
>
0
r4
.
add_parent
(
"
bla bla
"
)
with
raises
(
RuntimeError
,
match
=
"
.*1 parent.*
"
):
create_hash_string
(
r4
)
def
test_file_hash_creation
():
f1
=
db
.
File
(
path
=
"
/bla/bla/test1.txt
"
)
hash1
=
create_hash_string
(
f1
)
f2
=
db
.
File
(
path
=
"
/bla/bla/test2.txt
"
)
hash2
=
create_hash_string
(
f2
)
assert
hash1
!=
hash2
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