Skip to content
Snippets Groups Projects

F convenience

Merged Alexander Kreft requested to merge f-convenience into dev
1 file
+ 60
3
Compare changes
  • Side-by-side
  • Inline
+ 60
3
@@ -196,7 +196,7 @@ end
@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_name(prop) == "TestProperty" #TODO Why the name is unit?
#@test get_unit(prop) == "cm"
# 3. delete
@@ -210,7 +210,32 @@ end
@test has_errors(results[1]) == false
@test get_id(results[1]) != ""
# 4. Cleanup
# 4. Convenience functions
ent_with_name = CaosDB.Entity.create_recordtype("TestEnt")
results = insert_entity(ent_with_name)
@test length(results) == 1
@test has_errors(results[1]) == false
@test get_id(results[1]) != ""
ent_with_name = execute_query("FIND TestEnt")
prop_with_name = execute_query("Find TestProperty")
prop = CaosDB.Entity.create_property(id = get_id(prop_with_name[1]))
CaosDB.Entity.append_property(ent_with_name[1], prop)
results = update_entity(ent_with_name[1])
@test length(results) == 1
@test has_errors(results[1]) == false
@test get_id(results[1]) != ""
ent_with_name = execute_query("FIND TestEnt")
results = delete_by_id(get_id(ent_with_name[1]))
@test length(results) == 1
@test has_errors(results[1]) == false
@test get_id(results[1]) != ""
# 5. Cleanup
ent_with_name = execute_query("FIND TestProperty")
cleanup_transaction = create_transaction()
add_delete_by_id(cleanup_transaction, get_id(ent_with_name[1]))
@@ -225,6 +250,7 @@ end
write(fname, "Some Content") # cannot be empty
upload_path = string(pwd(), "/", fname)
download_path = string(pwd(), "/", string(uuid4()))
download_path2 = string(pwd(), "/", string(uuid4()), "-2")
# 2. Upload Entity
ent_with_name = CaosDB.Entity.create_entity("TestFile")
@@ -258,14 +284,45 @@ end
@test get_id(results[1]) != ""
@test isfile(download_path) == true
# 4. Cleanup
# 4. Convenience functions
touch(fname)
write(fname, "Some Content")
file_ent_with_name = create_file_entity(
name = "TestFile2",
local_path = upload_path,
remote_path = string("/Inttests/", fname, "-2"),
)
results = insert_entity(file_ent_with_name)
@test length(results) == 1
@test has_errors(results[1]) == false
@test get_id(results[1]) != ""
file_ent_with_name = execute_query("FIND TestFile")
results =
retrieve_and_download_file_by_id(get_id(file_ent_with_name[1]), download_path2)
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_path2) == true
# 5. 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)
ent_with_name = execute_query("FIND TestFile2")
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)
rm(download_path2)
end
Loading