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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-julialib
Commits
c5d7fdd8
Commit
c5d7fdd8
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
TST: Add tests for reference datatypes
parent
3d094b27
No related branches found
No related tags found
1 merge request
!11
F get value
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/runtests.jl
+41
-3
41 additions, 3 deletions
test/runtests.jl
with
41 additions
and
3 deletions
test/runtests.jl
+
41
−
3
View file @
c5d7fdd8
...
@@ -147,9 +147,9 @@ using CaosDB
...
@@ -147,9 +147,9 @@ using CaosDB
# properties can be accessed as a list
# properties can be accessed as a list
# TODO(henrik, daniel)
# TODO(henrik, daniel)
#
@test CaosDB.Entity.get_value(
@test
CaosDB
.
Entity
.
get_value
(
#
CaosDB.Entity.get_properties(rec_with_parent_and_props)[1],
CaosDB
.
Entity
.
get_properties
(
rec_with_parent_and_props
)[
1
],
#
) == "2"
)
==
"2"
type
,
is_ref
,
is_list
=
CaosDB
.
Entity
.
get_datatype
(
type
,
is_ref
,
is_list
=
CaosDB
.
Entity
.
get_datatype
(
CaosDB
.
Entity
.
get_properties
(
rec_with_parent_and_props
)[
2
],
CaosDB
.
Entity
.
get_properties
(
rec_with_parent_and_props
)[
2
],
)
)
...
@@ -180,22 +180,31 @@ using CaosDB
...
@@ -180,22 +180,31 @@ using CaosDB
)
)
string_prop
=
string_prop
=
CaosDB
.
Entity
.
create_property_entity
(
name
=
"StringProp"
,
datatype
=
"TEXT"
)
CaosDB
.
Entity
.
create_property_entity
(
name
=
"StringProp"
,
datatype
=
"TEXT"
)
ref_prop
=
CaosDB
.
Entity
.
create_property_entity
(
name
=
"RefProp"
,
datatype
=
"MyRefType"
,
is_reference
=
true
,
)
CaosDB
.
Entity
.
set_value
(
int_prop
,
123
)
CaosDB
.
Entity
.
set_value
(
int_prop
,
123
)
CaosDB
.
Entity
.
set_value
(
double_prop
,
10.246
)
CaosDB
.
Entity
.
set_value
(
double_prop
,
10.246
)
CaosDB
.
Entity
.
set_value
(
bool_prop
,
true
)
CaosDB
.
Entity
.
set_value
(
bool_prop
,
true
)
CaosDB
.
Entity
.
set_value
(
string_prop
,
"Hello World"
)
CaosDB
.
Entity
.
set_value
(
string_prop
,
"Hello World"
)
CaosDB
.
Entity
.
set_value
(
ref_prop
,
"some_id"
)
@test
CaosDB
.
Entity
.
get_value
(
int_prop
)
==
123
@test
CaosDB
.
Entity
.
get_value
(
int_prop
)
==
123
@test
CaosDB
.
Entity
.
get_value
(
double_prop
)
==
10.246
@test
CaosDB
.
Entity
.
get_value
(
double_prop
)
==
10.246
@test
CaosDB
.
Entity
.
get_value
(
bool_prop
)
===
true
@test
CaosDB
.
Entity
.
get_value
(
bool_prop
)
===
true
@test
CaosDB
.
Entity
.
get_value
(
string_prop
)
==
"Hello World"
@test
CaosDB
.
Entity
.
get_value
(
string_prop
)
==
"Hello World"
@test
CaosDB
.
Entity
.
get_value
(
ref_prop
)
==
"some_id"
@test
isa
(
CaosDB
.
Entity
.
get_value
(
int_prop
),
Integer
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
int_prop
),
Integer
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
double_prop
),
Number
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
double_prop
),
Number
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
bool_prop
),
Bool
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
bool_prop
),
Bool
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
string_prop
),
String
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
string_prop
),
String
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
ref_prop
),
String
)
@test
CaosDB
.
Entity
.
get_datatype
(
int_prop
)
==
(
"INTEGER"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
int_prop
)
==
(
"INTEGER"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
double_prop
)
==
(
"DOUBLE"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
double_prop
)
==
(
"DOUBLE"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
bool_prop
)
==
(
"BOOLEAN"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
bool_prop
)
==
(
"BOOLEAN"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
string_prop
)
==
(
"TEXT"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
string_prop
)
==
(
"TEXT"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
ref_prop
)
==
(
"MyRefType"
,
true
,
false
)
""" Test lists """
""" Test lists """
int_list_prop
=
CaosDB
.
Entity
.
create_property_entity
(
int_list_prop
=
CaosDB
.
Entity
.
create_property_entity
(
...
@@ -218,22 +227,32 @@ using CaosDB
...
@@ -218,22 +227,32 @@ using CaosDB
datatype
=
"TEXT"
,
datatype
=
"TEXT"
,
is_list
=
true
,
is_list
=
true
,
)
)
ref_list_prop
=
CaosDB
.
Entity
.
create_property_entity
(
name
=
"RefListProp"
,
datatype
=
"MyRefType"
,
is_list
=
true
,
is_reference
=
true
,
)
CaosDB
.
Entity
.
set_value
(
int_list_prop
,
[
123
,
456
])
CaosDB
.
Entity
.
set_value
(
int_list_prop
,
[
123
,
456
])
CaosDB
.
Entity
.
set_value
(
double_list_prop
,
[
10.246
,
3.14
])
CaosDB
.
Entity
.
set_value
(
double_list_prop
,
[
10.246
,
3.14
])
CaosDB
.
Entity
.
set_value
(
bool_list_prop
,
[
true
,
false
])
CaosDB
.
Entity
.
set_value
(
bool_list_prop
,
[
true
,
false
])
CaosDB
.
Entity
.
set_value
(
string_list_prop
,
[
"Hello"
,
"World"
])
CaosDB
.
Entity
.
set_value
(
string_list_prop
,
[
"Hello"
,
"World"
])
CaosDB
.
Entity
.
set_value
(
ref_list_prop
,
[
"some_id"
,
"another_id"
])
@test
CaosDB
.
Entity
.
get_value
(
int_list_prop
)
==
[
123
,
456
]
@test
CaosDB
.
Entity
.
get_value
(
int_list_prop
)
==
[
123
,
456
]
@test
CaosDB
.
Entity
.
get_value
(
double_list_prop
)
==
[
10.246
,
3.14
]
@test
CaosDB
.
Entity
.
get_value
(
double_list_prop
)
==
[
10.246
,
3.14
]
@test
CaosDB
.
Entity
.
get_value
(
bool_list_prop
)
===
[
true
,
false
]
@test
CaosDB
.
Entity
.
get_value
(
bool_list_prop
)
===
[
true
,
false
]
@test
CaosDB
.
Entity
.
get_value
(
string_list_prop
)
==
[
"Hello"
,
"World"
]
@test
CaosDB
.
Entity
.
get_value
(
string_list_prop
)
==
[
"Hello"
,
"World"
]
@test
CaosDB
.
Entity
.
get_value
(
ref_list_prop
)
==
[
"some_id"
,
"another_id"
]
@test
isa
(
CaosDB
.
Entity
.
get_value
(
int_list_prop
),
Vector
{
Cint
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
int_list_prop
),
Vector
{
Cint
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
double_list_prop
),
Vector
{
Cdouble
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
double_list_prop
),
Vector
{
Cdouble
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
bool_list_prop
),
Vector
{
Bool
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
bool_list_prop
),
Vector
{
Bool
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
string_list_prop
),
Vector
{
String
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
string_list_prop
),
Vector
{
String
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
ref_list_prop
),
Vector
{
String
})
@test
CaosDB
.
Entity
.
get_datatype
(
int_list_prop
)
==
(
"INTEGER"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
int_list_prop
)
==
(
"INTEGER"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
double_list_prop
)
==
(
"DOUBLE"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
double_list_prop
)
==
(
"DOUBLE"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
bool_list_prop
)
==
(
"BOOLEAN"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
bool_list_prop
)
==
(
"BOOLEAN"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
string_list_prop
)
==
(
"TEXT"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
string_list_prop
)
==
(
"TEXT"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
ref_list_prop
)
==
(
"MyRefType"
,
true
,
true
)
end
end
@testset
"Property properties"
begin
@testset
"Property properties"
begin
int_prop
=
CaosDB
.
Entity
.
create_property
(
name
=
"IntProp"
,
datatype
=
"INTEGER"
)
int_prop
=
CaosDB
.
Entity
.
create_property
(
name
=
"IntProp"
,
datatype
=
"INTEGER"
)
...
@@ -243,22 +262,31 @@ using CaosDB
...
@@ -243,22 +262,31 @@ using CaosDB
CaosDB
.
Entity
.
create_property
(
name
=
"BoolProp"
,
datatype
=
"BOOLEAN"
)
CaosDB
.
Entity
.
create_property
(
name
=
"BoolProp"
,
datatype
=
"BOOLEAN"
)
string_prop
=
string_prop
=
CaosDB
.
Entity
.
create_property
(
name
=
"StringProp"
,
datatype
=
"TEXT"
)
CaosDB
.
Entity
.
create_property
(
name
=
"StringProp"
,
datatype
=
"TEXT"
)
ref_prop
=
CaosDB
.
Entity
.
create_property
(
name
=
"RefProp"
,
datatype
=
"MyRefType"
,
is_reference
=
true
,
)
CaosDB
.
Entity
.
set_value
(
int_prop
,
123
)
CaosDB
.
Entity
.
set_value
(
int_prop
,
123
)
CaosDB
.
Entity
.
set_value
(
double_prop
,
10.246
)
CaosDB
.
Entity
.
set_value
(
double_prop
,
10.246
)
CaosDB
.
Entity
.
set_value
(
bool_prop
,
true
)
CaosDB
.
Entity
.
set_value
(
bool_prop
,
true
)
CaosDB
.
Entity
.
set_value
(
string_prop
,
"Hello World"
)
CaosDB
.
Entity
.
set_value
(
string_prop
,
"Hello World"
)
CaosDB
.
Entity
.
set_value
(
ref_prop
,
"some_id"
)
@test
CaosDB
.
Entity
.
get_value
(
int_prop
)
==
123
@test
CaosDB
.
Entity
.
get_value
(
int_prop
)
==
123
@test
CaosDB
.
Entity
.
get_value
(
double_prop
)
==
10.246
@test
CaosDB
.
Entity
.
get_value
(
double_prop
)
==
10.246
@test
CaosDB
.
Entity
.
get_value
(
bool_prop
)
===
true
@test
CaosDB
.
Entity
.
get_value
(
bool_prop
)
===
true
@test
CaosDB
.
Entity
.
get_value
(
string_prop
)
==
"Hello World"
@test
CaosDB
.
Entity
.
get_value
(
string_prop
)
==
"Hello World"
@test
CaosDB
.
Entity
.
get_value
(
ref_prop
)
==
"some_id"
@test
isa
(
CaosDB
.
Entity
.
get_value
(
int_prop
),
Integer
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
int_prop
),
Integer
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
double_prop
),
Number
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
double_prop
),
Number
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
bool_prop
),
Bool
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
bool_prop
),
Bool
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
string_prop
),
String
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
string_prop
),
String
)
@test
isa
(
CaosDB
.
Entity
.
get_value
(
ref_prop
),
String
)
@test
CaosDB
.
Entity
.
get_datatype
(
int_prop
)
==
(
"INTEGER"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
int_prop
)
==
(
"INTEGER"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
double_prop
)
==
(
"DOUBLE"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
double_prop
)
==
(
"DOUBLE"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
bool_prop
)
==
(
"BOOLEAN"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
bool_prop
)
==
(
"BOOLEAN"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
string_prop
)
==
(
"TEXT"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
string_prop
)
==
(
"TEXT"
,
false
,
false
)
@test
CaosDB
.
Entity
.
get_datatype
(
ref_prop
)
==
(
"MyRefType"
,
true
,
false
)
""" Test lists """
""" Test lists """
int_list_prop
=
CaosDB
.
Entity
.
create_property
(
int_list_prop
=
CaosDB
.
Entity
.
create_property
(
...
@@ -281,22 +309,32 @@ using CaosDB
...
@@ -281,22 +309,32 @@ using CaosDB
datatype
=
"TEXT"
,
datatype
=
"TEXT"
,
is_list
=
true
,
is_list
=
true
,
)
)
ref_list_prop
=
CaosDB
.
Entity
.
create_property
(
name
=
"RefListProp"
,
datatype
=
"MyRefType"
,
is_list
=
true
,
is_reference
=
true
,
)
CaosDB
.
Entity
.
set_value
(
int_list_prop
,
[
123
,
456
])
CaosDB
.
Entity
.
set_value
(
int_list_prop
,
[
123
,
456
])
CaosDB
.
Entity
.
set_value
(
double_list_prop
,
[
10.246
,
3.14
])
CaosDB
.
Entity
.
set_value
(
double_list_prop
,
[
10.246
,
3.14
])
CaosDB
.
Entity
.
set_value
(
bool_list_prop
,
[
true
,
false
])
CaosDB
.
Entity
.
set_value
(
bool_list_prop
,
[
true
,
false
])
CaosDB
.
Entity
.
set_value
(
string_list_prop
,
[
"Hello"
,
"World"
])
CaosDB
.
Entity
.
set_value
(
string_list_prop
,
[
"Hello"
,
"World"
])
CaosDB
.
Entity
.
set_value
(
ref_list_prop
,
[
"some_id"
,
"another_id"
])
@test
CaosDB
.
Entity
.
get_value
(
int_list_prop
)
==
[
123
,
456
]
@test
CaosDB
.
Entity
.
get_value
(
int_list_prop
)
==
[
123
,
456
]
@test
CaosDB
.
Entity
.
get_value
(
double_list_prop
)
==
[
10.246
,
3.14
]
@test
CaosDB
.
Entity
.
get_value
(
double_list_prop
)
==
[
10.246
,
3.14
]
@test
CaosDB
.
Entity
.
get_value
(
bool_list_prop
)
===
[
true
,
false
]
@test
CaosDB
.
Entity
.
get_value
(
bool_list_prop
)
===
[
true
,
false
]
@test
CaosDB
.
Entity
.
get_value
(
string_list_prop
)
==
[
"Hello"
,
"World"
]
@test
CaosDB
.
Entity
.
get_value
(
string_list_prop
)
==
[
"Hello"
,
"World"
]
@test
CaosDB
.
Entity
.
get_value
(
ref_list_prop
)
==
[
"some_id"
,
"another_id"
]
@test
isa
(
CaosDB
.
Entity
.
get_value
(
int_list_prop
),
Vector
{
Cint
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
int_list_prop
),
Vector
{
Cint
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
double_list_prop
),
Vector
{
Cdouble
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
double_list_prop
),
Vector
{
Cdouble
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
bool_list_prop
),
Vector
{
Bool
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
bool_list_prop
),
Vector
{
Bool
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
string_list_prop
),
Vector
{
String
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
string_list_prop
),
Vector
{
String
})
@test
isa
(
CaosDB
.
Entity
.
get_value
(
ref_list_prop
),
Vector
{
String
})
@test
CaosDB
.
Entity
.
get_datatype
(
int_list_prop
)
==
(
"INTEGER"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
int_list_prop
)
==
(
"INTEGER"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
double_list_prop
)
==
(
"DOUBLE"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
double_list_prop
)
==
(
"DOUBLE"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
bool_list_prop
)
==
(
"BOOLEAN"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
bool_list_prop
)
==
(
"BOOLEAN"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
string_list_prop
)
==
(
"TEXT"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
string_list_prop
)
==
(
"TEXT"
,
false
,
true
)
@test
CaosDB
.
Entity
.
get_datatype
(
ref_list_prop
)
==
(
"MyRefType"
,
true
,
true
)
end
end
end
end
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