Skip to content
Snippets Groups Projects
Commit 8f6d3528 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

DOC: updated merge_entities docstr to note that the function is currently experimental

parent a68883c4
No related branches found
No related tags found
2 merge requests!57RELEASE 0.7.3,!45F copy entity
Pipeline #21662 passed with warnings
......@@ -39,6 +39,8 @@ from caosdb.common.models import (Container, Entity, File, Property, Query,
Record, RecordType, execute_query,
get_config, SPECIAL_ATTRIBUTES)
import logging
def new_record(record_type, name=None, description=None,
tempid=None, insert=False, **kwargs):
......@@ -689,8 +691,13 @@ def merge_entities(entity_a: Entity, entity_b: Entity):
The merge operation is done in place.
Returns entity_a.
WARNING: This function is currently experimental and insufficiently tested. Use with care.
"""
logging.warning(
"This function is currently experimental and insufficiently tested. Use with care.")
# Compare both entities:
diff_r1, diff_r2 = compare_entities(entity_a, entity_b)
......
......@@ -33,6 +33,8 @@ import caosdb.apiutils
from caosdb.apiutils import (apply_to_ids, compare_entities, create_id_query,
resolve_reference, merge_entities)
from caosdb.common.models import SPECIAL_ATTRIBUTES
from .test_property import testrecord
import pytest
......@@ -247,12 +249,13 @@ def test_copy_entities():
assert c.name == "A"
assert c.role == r.role
assert c.parents[0].name == "B"
# Currently parents and properties are always individual to a copy:
assert c.parents[0] != r.parents[0]
# parent and property objects are not shared among copy and original:
assert c.parents[0] is not r.parents[0]
for i in [0, 1]:
assert c.properties[i] != r.properties[i]
assert c.properties[i].value == r.properties[i].value
assert c.properties[i] is not r.properties[i]
for special in SPECIAL_ATTRIBUTES:
assert getattr(c.properties[i], special) == getattr(r.properties[i], special)
assert c.get_importance(c.properties[i]) == r.get_importance(r.properties[i])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment