Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-julialib
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-julialib
Commits
f5bd5529
Commit
f5bd5529
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Add test for entities
parent
2b379aff
No related branches found
No related tags found
1 merge request
!7
ENH: Implement queries and entity retrieval
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/runtests.jl
+66
-1
66 additions, 1 deletion
test/runtests.jl
with
66 additions
and
1 deletion
test/runtests.jl
+
66
−
1
View file @
f5bd5529
...
...
@@ -63,6 +63,13 @@ using CaosDB
Cint
(
-
1
),
),
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
-
1
))
# Check whether client errors can be built correctly and
# return the correct code (Change it if this ever changes in
# libcaosdb)
client_err
=
CaosDB
.
Exceptions
.
ClientException
(
"Client error"
)
@test
client_err
.
msg
==
"Client_Err"
@test
client_err
.
code
==
9999
end
@testset
"TestTransaction"
begin
...
...
@@ -84,5 +91,63 @@ using CaosDB
end
@testset
"TestEntity"
begin
end
@testset
"TestEntity"
begin
ent_with_name
=
CaosDB
.
Entity
.
create_entity
(
"TestEnt"
)
@test
CaosDB
.
Entity
.
get_name
(
ent_with_name
)
==
"TestEnt"
rt_with_name
=
CaosDB
.
Entity
.
create_recordtype
(
"TestRT"
)
@test
CaosDB
.
Entity
.
get_name
(
rt_with_name
)
==
"TestRT"
@test
CaosDB
.
Entity
.
get_role
(
rt_with_name
)
==
"RecordType"
prop_with_name_and_unit
=
CaosDB
.
Entity
.
create_property_entity
(
name
=
"TestProp"
,
unit
=
"m"
)
@test
CaosDB
.
Entity
.
get_name
(
prop_with_name_and_unit
)
==
"TestProp"
@test
CaosDB
.
Entity
.
get_role
(
prop_with_name_and_unit
)
==
"Property"
@test
CaosDB
.
Entity
.
get_unit
(
prop_with_name_and_unit
)
==
"m"
rec_with_parent_and_props
=
CaosDB
.
Entity
.
create_record
(
"TestRec"
)
# cannot set an ID
@test_throws
CaosDB
.
Exceptions
.
ClientException
CaosDB
.
Entity
.
set_id
(
"some_id"
)
par1
=
CaosDB
.
Entity
.
create_parent
(
name
=
"Parent1"
)
par2
=
CaosDB
.
Entity
.
create_parent
(
name
=
"Parent2"
,
id
=
"id_of_parent_2"
)
CaosDB
.
Entity
.
append_parents
(
rec_with_parent_and_props
,
[
par1
,
par2
])
@test
length
(
CaosDB
.
Entity
.
get_parents
(
rec_with_parent_and_props
))
==
2
@test
CaosDB
.
Entity
.
get_name
(
CaosDB
.
Entity
.
get_parent
(
rec_with_parent_and_props
,
1
),
)
==
"Parent1"
@test
CaosDB
.
Entity
.
get_name
(
CaosDB
.
Entity
.
get_parent
(
rec_with_parent_and_props
,
2
),
)
==
"Parent2"
@test
CaosDB
.
Entity
.
get_id
(
CaosDB
.
Entity
.
get_parent
(
rec_with_parent_and_props
,
2
),
)
==
"id_of_parent_2"
CaosDB
.
Entity
.
remove_parent
(
rec_with_parent_and_props
,
1
)
@test
length
(
CaosDB
.
Entity
.
get_parents
(
rec_with_parent_and_props
))
==
1
@test
CaosDB
.
Entity
.
get_name
(
CaosDB
.
Entity
.
get_parent
(
rec_with_parent_and_props
,
1
),
)
==
"Parent2"
prop1
=
CaosDB
.
Entity
.
create_property
(
name
=
"Property1"
,
value
=
"2"
)
prop2
=
CaosDB
.
Entity
.
create_property
(
id
=
"id_of_property_2"
)
CaosDB
.
Entity
.
set_datatype
(
prop2
,
"TEXT"
)
prop3
=
CaosDB
.
Entity
.
create_property
(
name
=
"Property3"
)
CaosDB
.
Entity
.
append_properties
(
rec_with_parent_and_props
,
[
prop1
,
prop2
,
prop3
])
@test
length
(
CaosDB
.
Entity
.
get_properties
(
rec_with_parent_and_props
))
==
3
# properties can be accessed as a list
@test
CaosDB
.
Entity
.
get_value
(
CaosDB
.
Entity
.
get_properties
(
rec_with_parent_and_props
)[
1
],
)
==
"2"
@test
CaosDB
.
Entity
.
get_datatype
(
CaosDB
.
Entity
.
get_properties
(
rec_with_parent_and_props
)[
2
],
)
==
"TEXT"
@test
CaosDB
.
Entity
.
get_id
(
CaosDB
.
Entity
.
get_properties
(
rec_with_parent_and_props
)[
2
],
)
==
"id_of_property_2"
CaosDB
.
Entity
.
remove_property
(
rec_with_parent_and_props
,
2
)
@test
length
(
CaosDB
.
Entity
.
get_properties
(
rec_with_parent_and_props
))
==
2
@test
CaosDB
.
Entity
.
get_name
(
CaosDB
.
Entity
.
get_properties
(
rec_with_parent_and_props
)[
2
],
)
==
"Property3"
end
end
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