Skip to content
Snippets Groups Projects
Commit 54fcd481 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

Merge branch 'f-role' into 'dev'

TST: add tests for get_entity...

See merge request !78
parents 37ab0837 2d1edf51
No related branches found
No related tags found
1 merge request!78TST: add tests for get_entity...
Pipeline #51739 passed
......@@ -32,6 +32,7 @@ import random
import caosdb as db
from caosdb.connection.connection import get_connection
from linkahead.utils.get_entity import get_entity_by_name, get_entity_by_id, get_entity_by_path
from caosdb.exceptions import EmptyUniqueQueryError, TransactionError
from lxml import etree
from pytest import mark, raises
......@@ -1470,3 +1471,25 @@ def test_find_id():
assert db.execute_query("FIND TestRT3 WITH TestRT1", unique=True).id == rt3.id
assert db.execute_query(f"FIND {rt2.id} WITH TestRT1", unique=True).id == rt3.id
assert db.execute_query(f"FIND {rt3.id} WITH TestRT1", unique=True).id == rt3.id
def test_get_entity():
person = db.RecordType("TestPerson").insert()
db.Property("TestFirstName", datatype=db.TEXT).insert()
con = db.Property("TestConductor", datatype=db.REFERENCE).insert()
db.RecordType("TestConductor").insert(unique=False)
# create testfile
f = open("test.dat", "w")
f.write("hello world\n")
f.close()
''' prepare file record '''
f = db.File(name="TestFile", path='testfiles/testfile', file="test.dat")
f.insert()
assert get_entity_by_id(person.id).id == person.id
assert get_entity_by_name(person.name).id == person.id
assert get_entity_by_id(person.id, role="RecordType").id == person.id
assert get_entity_by_name("TestConductor", role="Property").id == con.id
assert get_entity_by_path(f.path).id == f.id
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment