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
ad0f2a8d
Commit
ad0f2a8d
authored
2 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
TST: Add tests for new identifiable-query quotation
parent
c98d1acf
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!123
REL: Release v0.6.0
,
!118
f-special-chars-in-names
Pipeline
#37114
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
unittests/test_identifiable_adapters.py
+10
-6
10 additions, 6 deletions
unittests/test_identifiable_adapters.py
with
10 additions
and
6 deletions
unittests/test_identifiable_adapters.py
+
10
−
6
View file @
ad0f2a8d
...
...
@@ -44,7 +44,7 @@ UNITTESTDIR = Path(__file__).parent
def
test_create_query_for_identifiable
():
query
=
IdentifiableAdapter
.
create_query_for_identifiable
(
Identifiable
(
record_type
=
"
Person
"
,
properties
=
{
"
first_name
"
:
"
A
"
,
"
last_name
"
:
"
B
"
}))
assert
query
.
lower
()
==
"
find record person with
'
first_name
'
=
'
a
'
and
'
last_name
'
=
'
b
'
"
assert
query
.
lower
()
==
"
find record
'
person
'
with
'
first_name
'
=
'
a
'
and
'
last_name
'
=
'
b
'
"
query
=
IdentifiableAdapter
.
create_query_for_identifiable
(
Identifiable
(
name
=
"
A
"
,
record_type
=
"
B
"
,
properties
=
{
...
...
@@ -56,31 +56,31 @@ def test_create_query_for_identifiable():
"
h
"
:
db
.
Record
(
id
=
1111
),
"
i
"
:
db
.
File
(
id
=
1112
),
"
j
"
:
[
2222
,
db
.
Record
(
id
=
3333
)]}))
assert
(
query
==
"
FIND RECORD
B
WITH name=
'
A
'
AND
'
c
'
=
'
c
'
AND
'
d
'
=
'
5
'
AND
'
e
'
=
'
5.5
'"
assert
(
query
==
"
FIND RECORD
'
B
'
WITH name=
'
A
'
AND
'
c
'
=
'
c
'
AND
'
d
'
=
'
5
'
AND
'
e
'
=
'
5.5
'"
"
AND
'
f
'
=
'
2020-10-10T00:00:00
'
AND
'
g
'
=
'
TRUE
'
AND
'
h
'
=
'
1111
'
AND
'
i
'
=
'
1112
'
AND
"
"'
j
'
=
'
2222
'
AND
'
j
'
=
'
3333
'
"
)
# The name can be the only identifiable
query
=
IdentifiableAdapter
.
create_query_for_identifiable
(
Identifiable
(
name
=
"
TestRecord
"
,
record_type
=
"
TestType
"
))
assert
query
.
lower
()
==
"
find record testtype with name=
'
testrecord
'"
assert
query
.
lower
()
==
"
find record
'
testtype
'
with name=
'
testrecord
'"
# With referencing entity (backref)
query
=
IdentifiableAdapter
.
create_query_for_identifiable
(
Identifiable
(
record_type
=
"
Person
"
,
backrefs
=
[
14433
],
properties
=
{
'
last_name
'
:
"
B
"
}))
assert
query
.
lower
()
==
(
"
find record person which is referenced by 14433 and with
"
assert
query
.
lower
()
==
(
"
find record
'
person
'
which is referenced by 14433 and with
"
"'
last_name
'
=
'
b
'
"
)
# With two referencing entities (backref)
query
=
IdentifiableAdapter
.
create_query_for_identifiable
(
Identifiable
(
record_type
=
"
Person
"
,
backrefs
=
[
14433
,
333
],
properties
=
{
'
last_name
'
:
"
B
"
}))
assert
query
.
lower
()
==
(
"
find record person which is referenced by 14433 and which is
"
assert
query
.
lower
()
==
(
"
find record
'
person
'
which is referenced by 14433 and which is
"
"
referenced by 333 and with
'
last_name
'
=
'
b
'
"
)
# With single quote in string
query
=
IdentifiableAdapter
.
create_query_for_identifiable
(
Identifiable
(
record_type
=
"
Person
"
,
backrefs
=
[],
properties
=
{
'
last_name
'
:
"
B
'
Or
"
}))
assert
query
==
(
"
FIND RECORD Person WITH
'
last_name
'
=
'
B
\\
'
Or
'
"
)
assert
query
==
(
"
FIND RECORD
'
Person
'
WITH
'
last_name
'
=
'
B
\\
'
Or
'
"
)
# With only backref
query
=
IdentifiableAdapter
.
create_query_for_identifiable
(
...
...
@@ -92,6 +92,10 @@ def test_create_query_for_identifiable():
Identifiable
(
backrefs
=
[
160
],
name
=
'
lo
'
,
properties
=
{}))
assert
query
==
(
"
FIND RECORD WHICH IS REFERENCED BY 160 AND WITH name=
'
lo
'"
)
query
=
IdentifiableAdapter
.
create_query_for_identifiable
(
Identifiable
(
record_type
=
"
record type
"
,
name
=
"
it
'
s weird
"
))
assert
query
==
(
"
FIND RECORD
'
record type
'
WITH name=
'
it
\\
'
s weird
'"
)
def
test_load_from_yaml_file
():
ident
=
CaosDBIdentifiableAdapter
()
...
...
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