Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CaosDB Python Integration Tests
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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 Python Integration Tests
Commits
dc267ca9
Commit
dc267ca9
authored
4 years ago
by
Timm Fitschen
Committed by
Henrik tom Wörden
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Introduce tests for semantic select query
parent
e3f6f3a2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_select.py
+64
-3
64 additions, 3 deletions
tests/test_select.py
with
64 additions
and
3 deletions
tests/test_select.py
+
64
−
3
View file @
dc267ca9
...
...
@@ -41,15 +41,22 @@ def setup_module():
name
=
"
TestPropertyOne
"
,
value
=
"
v1
"
).
add_property
(
name
=
"
TestPropertyTwo
"
,
value
=
"
v2
"
).
insert
()
rt_house
=
db
.
RecordType
(
"
TestHouse
"
,
description
=
"
TestHouseDesc
"
).
insert
()
db
.
RecordType
(
"
TestWindow
"
).
insert
()
db
.
RecordType
(
"
TestHousePart
"
,
description
=
"
TestHousePartDesc
"
).
insert
()
db
.
RecordType
(
"
TestWindow
"
).
add_parent
(
"
TestHousePart
"
).
insert
()
db
.
RecordType
(
"
TestDoor
"
).
add_parent
(
"
TestHousePart
"
).
insert
()
rt_person
=
db
.
RecordType
(
"
TestPerson
"
,
description
=
"
TestPersonDesc
"
).
insert
()
db
.
RecordType
(
"
TestParty
"
,
description
=
"
TestPartyDesc
"
).
insert
()
db
.
Property
(
"
TestHouseProperty
"
,
datatype
=
db
.
TEXT
).
insert
()
db
.
Property
(
"
TestHeight
"
,
description
=
"
TestHeightDesc
"
,
datatype
=
db
.
DOUBLE
,
unit
=
"
ft
"
).
insert
()
unit
=
"
ft
"
).
add_parent
(
"
TestHouseProperty
"
).
insert
()
db
.
Property
(
"
TestDate
"
,
description
=
"
TestDateDesc
"
,
datatype
=
db
.
DATETIME
).
insert
()
door
=
db
.
Record
(
"
Door1
"
,
description
=
"
Door1Desc
"
).
add_parent
(
"
TestDoor
"
)
door
.
add_property
(
"
TestHeight
"
,
"
21.5
"
,
unit
=
"
ft
"
)
door
.
insert
()
window
=
db
.
Record
(
"
Window1
"
,
description
=
"
Window1Desc
"
).
add_parent
(
"
TestWindow
"
)
window
.
add_property
(
"
TestHeight
"
,
20.5
,
unit
=
"
ft
"
)
...
...
@@ -61,7 +68,9 @@ def setup_module():
house
.
description
=
"
A rather large house
"
house
.
add_parent
(
"
TestHouse
"
)
house
.
add_property
(
rt_person
,
name
=
"
TestOwner
"
,
value
=
owner
)
house
.
add_property
(
"
TestWindow
"
,
window
).
insert
()
house
.
add_property
(
"
TestWindow
"
,
window
)
house
.
add_property
(
"
TestDoor
"
,
door
)
house
.
insert
()
g1
=
db
.
Record
().
add_parent
(
"
TestPerson
"
).
insert
()
g2
=
db
.
Record
().
add_parent
(
"
TestPerson
"
).
insert
()
...
...
@@ -326,3 +335,55 @@ def test_select_name():
"
RECORD TestWindow
"
,
unique
=
True
)
column
=
s
.
get_property_values
((
"
TestHeight
"
,
"
name
"
,
"
TestWindow
"
))
assert
column
==
(
None
,)
def
test_select_with_subtyping_semantics
():
s
=
db
.
execute_query
(
"
SELECT name FROM RECORD TestHouse WITH TestHousePart
"
,
unique
=
True
)
column
=
s
.
get_property_values
(
"
name
"
)
assert
column
==
(
"
Buckingham Palace
"
,)
s
=
db
.
execute_query
(
"
SELECT TestWindow.TestHeight FROM RECORD TestHouse WITH TestHousePart
"
,
unique
=
True
)
column
=
s
.
get_property_values
((
"
TestWindow
"
,
"
TestHeight
"
))
assert
column
==
(
20.5
,)
s
=
db
.
execute_query
(
"
SELECT TestHousePart.TestHeight FROM RECORD TestHouse WITH TestHousePart
"
,
unique
=
True
)
column
=
s
.
get_property_values
((
"
TestHousePart
"
,
"
TestHeight
"
))
# this is a current limitation of get_property_values which will only
# return the value of the first matching property
assert
column
==
(
20.5
,)
assert
len
(
s
.
properties
)
==
2
# both the door and the window have been returned
assert
(
s
.
properties
[
0
].
name
,
s
.
properties
[
1
].
name
)
==
(
"
TestHousePart
"
,
"
TestHousePart
"
)
assert
(
s
.
properties
[
0
].
value
.
properties
[
0
].
value
,
s
.
properties
[
1
].
value
.
properties
[
0
].
value
)
==
(
20.5
,
21.5
)
def
test_select_with_subtyping_semantics_second_level
():
s
=
db
.
execute_query
(
"
SELECT TestHousePart.TestHouseProperty FROM RECORD TestHouse WITH TestHousePart
"
,
unique
=
True
)
column
=
s
.
get_property_values
((
"
TestHousePart
"
,
"
TestHouseProperty
"
))
# this is a current limitation of get_property_values which will only
# return the value of the first matching property
assert
column
==
(
20.5
,)
assert
len
(
s
.
properties
)
==
2
# both the door and the window have been returned
assert
(
s
.
properties
[
0
].
name
,
s
.
properties
[
1
].
name
)
==
(
"
TestHousePart
"
,
"
TestHousePart
"
)
assert
(
s
.
properties
[
0
].
value
.
properties
[
0
].
value
,
s
.
properties
[
1
].
value
.
properties
[
0
].
value
)
==
(
20.5
,
21.5
)
def
test_select_with_subtyping_semantics_and_name_duplicates
():
db
.
Property
(
name
=
"
TestHousePart
"
,
description
=
"
This is a duplicate
"
,
datatype
=
db
.
TEXT
).
insert
(
unique
=
False
)
test_select_with_subtyping_semantics
()
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