Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CaosDB Julia Integration Tests
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 Julia Integration Tests
Commits
9ebcea89
Commit
9ebcea89
authored
3 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add tests insert, update, delete and file handling
parent
b4b3e50c
No related branches found
No related tags found
1 merge request
!5
F full
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/Project.toml
+1
-0
1 addition, 0 deletions
test/Project.toml
test/runtests.jl
+132
-0
132 additions, 0 deletions
test/runtests.jl
with
133 additions
and
0 deletions
test/Project.toml
+
1
−
0
View file @
9ebcea89
...
...
@@ -2,3 +2,4 @@
Logging
=
"56ddb016-857b-54e1-b83d-db4d58db5568"
Pkg
=
"44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test
=
"8dfed614-e22c-5e08-85e1-65c5234f0b40"
UUIDs
=
"cf7118a7-6976-5b1a-9a39-7adc72f591a4"
This diff is collapsed.
Click to expand it.
test/runtests.jl
+
132
−
0
View file @
9ebcea89
...
...
@@ -23,6 +23,7 @@
using
Test
using
Logging
using
UUIDs
# first try and load a local CaosDB installation; if that fails,
# set-up CaosDB.jl with repo and branch specified in
# `CaosDBIntegrationTests`. The latter is mainly useful for running
...
...
@@ -137,4 +138,135 @@ end
@test_throws
CaosDB
.
Exceptions
.
GenericCaosDBException
retrieve
([
"20"
,
"21"
,
"22"
])
end
@testset
"Test entity insertion, update and deletion"
begin
# 1. Insert
ent_with_name
=
CaosDB
.
Entity
.
create_recordtype
(
"TestEnt"
)
insert_rt_transaction
=
create_transaction
()
add_insert_entity
(
insert_rt_transaction
,
ent_with_name
)
execute
(
insert_rt_transaction
)
results
=
get_results
(
insert_rt_transaction
)
@test
length
(
results
)
==
1
@test
has_errors
(
results
[
1
])
==
false
@test
get_id
(
results
[
1
])
!=
""
# 2. update
ent_with_name
=
execute_query
(
"FIND TestEnt"
)
prop
=
CaosDB
.
Entity
.
create_property_entity
(
name
=
"TestProperty"
,
datatype
=
"TEXT"
,
unit
=
"cm"
,
is_reference
=
false
,
is_list
=
false
,
)
insert_prop_transaction
=
create_transaction
()
add_insert_entity
(
insert_prop_transaction
,
prop
)
execute
(
insert_prop_transaction
)
results
=
get_results
(
insert_prop_transaction
)
retrieve_prop_transaction
=
create_transaction
()
add_retrieve_by_id
(
retrieve_prop_transaction
,
get_id
(
results
[
1
]))
execute
(
retrieve_prop_transaction
)
results
=
get_results
(
retrieve_prop_transaction
)
@test
length
(
results
)
==
1
@test
has_errors
(
results
[
1
])
==
false
@test
get_name
(
results
[
1
])
==
"TestProperty"
#@test get_unit(results[1]) == "cm"
@test
get_datatype
(
results
[
1
])[
1
]
==
"TEXT"
prop2
=
CaosDB
.
Entity
.
create_property
(
id
=
get_id
(
results
[
1
]))
CaosDB
.
Entity
.
append_property
(
ent_with_name
[
1
],
prop2
)
update_transaction
=
create_transaction
()
add_update_entity
(
update_transaction
,
ent_with_name
[
1
])
execute
(
update_transaction
)
results
=
get_results
(
update_transaction
)
@test
length
(
results
)
==
1
retrieve_transaction
=
create_transaction
()
add_retrieve_by_id
(
retrieve_transaction
,
get_id
(
results
[
1
]))
execute
(
retrieve_transaction
)
results
=
get_results
(
retrieve_transaction
)
@test
length
(
results
)
==
1
@test
has_errors
(
results
[
1
])
==
false
@test
length
(
CaosDB
.
Entity
.
get_properties
(
results
[
1
]))
==
1
prop
=
CaosDB
.
Entity
.
get_property
(
results
[
1
],
1
)
@test
get_name
(
prop
)
==
"TestProperty"
#@test get_unit(prop) == "cm"
# 3. delete
ent_with_name
=
execute_query
(
"FIND TestEnt"
)
delete_transaction
=
create_transaction
()
add_delete_by_id
(
delete_transaction
,
get_id
(
ent_with_name
[
1
]))
execute
(
delete_transaction
)
results
=
get_results
(
delete_transaction
)
@test
length
(
results
)
==
1
@test
has_errors
(
results
[
1
])
==
false
@test
get_id
(
results
[
1
])
!=
""
# 4. Cleanup
ent_with_name
=
execute_query
(
"FIND TestProperty"
)
cleanup_transaction
=
create_transaction
()
add_delete_by_id
(
cleanup_transaction
,
get_id
(
ent_with_name
[
1
]))
execute
(
cleanup_transaction
)
end
@testset
"Test upload and download of a File"
begin
# 1. Setup
fname
=
string
(
uuid4
())
# file name
touch
(
fname
)
write
(
fname
,
"Some Content"
)
# cannot be empty
upload_path
=
string
(
pwd
(),
"/"
,
fname
)
download_path
=
string
(
pwd
(),
"/"
,
string
(
uuid4
()))
# 2. Upload Entity
ent_with_name
=
CaosDB
.
Entity
.
create_entity
(
"TestFile"
)
set_role
(
ent_with_name
,
"FILE"
)
set_local_path
(
ent_with_name
,
upload_path
)
set_remote_path
(
ent_with_name
,
string
(
"/Inttests/"
,
fname
))
single_insert_transaction
=
create_transaction
()
add_insert_entity
(
single_insert_transaction
,
ent_with_name
)
execute
(
single_insert_transaction
)
results
=
get_results
(
single_insert_transaction
)
@test
length
(
results
)
==
1
@test
has_errors
(
results
[
1
])
==
false
@test
get_id
(
results
[
1
])
!=
""
# 3. Download entity
ent_with_name
=
execute_query
(
"FIND TestFile"
)
single_insert_transaction
=
create_transaction
()
add_retrieve_and_download_file_by_id
(
single_insert_transaction
,
get_id
(
ent_with_name
[
1
]),
download_path
,
)
execute
(
single_insert_transaction
)
results
=
get_results
(
single_insert_transaction
)
@test
length
(
results
)
==
1
@test
has_errors
(
results
[
1
])
==
false
@test
get_id
(
results
[
1
])
!=
""
@test
isfile
(
download_path
)
==
true
# 4. Cleanup
ent_with_name
=
execute_query
(
"FIND TestFile"
)
single_insert_transaction
=
create_transaction
()
add_delete_by_id
(
single_insert_transaction
,
get_id
(
ent_with_name
[
1
]))
execute
(
single_insert_transaction
)
rm
(
upload_path
)
rm
(
download_path
)
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