Skip to content
Snippets Groups Projects
Commit c24d57bb authored by Alexander Kreft's avatar Alexander Kreft
Browse files

import caosdb as db

parent 47991123
Branches
Tags
1 merge request!14F delete container
...@@ -25,28 +25,28 @@ ...@@ -25,28 +25,28 @@
"""Tests for the Container class.""" """Tests for the Container class."""
from __future__ import absolute_import from __future__ import absolute_import
import caosdb as c import caosdb as db
def test_get_property_values(): def test_get_property_values():
rt_house = c.RecordType("House") rt_house = db.RecordType("House")
rt_window = c.RecordType("Window") rt_window = db.RecordType("Window")
rt_owner = c.RecordType("Owner") rt_owner = db.RecordType("Owner")
p_height = c.Property("Height", datatype=c.DOUBLE) p_height = db.Property("Height", datatype=db.DOUBLE)
window = c.Record().add_parent(rt_window) window = db.Record().add_parent(rt_window)
window.id = 1001 window.id = 1001
window.add_property(p_height, 20.5, unit="m") window.add_property(p_height, 20.5, unit="m")
owner = c.Record("The Queen").add_parent(rt_owner) owner = db.Record("The Queen").add_parent(rt_owner)
house = c.Record("Buckingham Palace") house = db.Record("Buckingham Palace")
house.add_parent(rt_house) house.add_parent(rt_house)
house.add_property(rt_owner, owner) house.add_property(rt_owner, owner)
house.add_property(rt_window, window) house.add_property(rt_window, window)
house.add_property(p_height, 40.2, unit="ft") house.add_property(p_height, 40.2, unit="ft")
container = c.Container() container = db.Container()
container.extend([ container.extend([
house, house,
owner owner
...@@ -80,40 +80,40 @@ def test_get_property_values(): ...@@ -80,40 +80,40 @@ def test_get_property_values():
def test_container_dependencies_for_deletion(): def test_container_dependencies_for_deletion():
rt = c.RecordType("Just a RecordType") rt = db.RecordType("Just a RecordType")
rt.id = 1001 rt.id = 1001
rt_dep = c.RecordType("Just another RecordType") rt_dep = db.RecordType("Just another RecordType")
rt_dep.id = 1002 rt_dep.id = 1002
rt_record_without_dependencies = c.RecordType( rt_record_without_dependencies = db.RecordType(
"Records without dependencies") "Records without dependencies")
rt_record_without_dependencies.id = 1003 rt_record_without_dependencies.id = 1003
rt_record_with_dependencies = c.RecordType("Records with dependencies") rt_record_with_dependencies = db.RecordType("Records with dependencies")
rt_record_with_dependencies.id = 1004 rt_record_with_dependencies.id = 1004
rt_record_with_parent = c.RecordType("Records with parent") rt_record_with_parent = db.RecordType("Records with parent")
rt_record_with_parent.id = 1005 rt_record_with_parent.id = 1005
property_which_is_not_a_record = c.Property( property_which_is_not_a_record = db.Property(
"Normal Property", datatype=c.DOUBLE, value=1006) "Normal Property", datatype=db.DOUBLE, value=1006)
property_which_is_not_a_record.id = 1006 property_which_is_not_a_record.id = 1006
record_without_dependencies = c.Record().add_parent(rt_record_without_dependencies) record_without_dependencies = db.Record().add_parent(rt_record_without_dependencies)
record_without_dependencies.id = 2003 record_without_dependencies.id = 2003
record_dep = c.Record().add_parent(rt_dep) record_dep = db.Record().add_parent(rt_dep)
record_dep.id = 2002 record_dep.id = 2002
record_with_dependencies = c.Record().add_parent(rt_record_with_dependencies) record_with_dependencies = db.Record().add_parent(rt_record_with_dependencies)
record_with_dependencies.id = 2004 record_with_dependencies.id = 2004
record_with_dependencies.add_property(rt_dep, record_dep) record_with_dependencies.add_property(rt_dep, record_dep)
record_with_parent = c.Record().add_parent(rt_record_with_parent) record_with_parent = db.Record().add_parent(rt_record_with_parent)
record_with_parent.id = 2005 record_with_parent.id = 2005
record_with_property_which_is_not_a_record = c.Record( record_with_property_which_is_not_a_record = db.Record(
).add_parent(rt_record_without_dependencies) ).add_parent(rt_record_without_dependencies)
record_with_property_which_is_not_a_record.id = 2006 record_with_property_which_is_not_a_record.id = 2006
record_with_property_which_is_not_a_record.add_property( record_with_property_which_is_not_a_record.add_property(
property_which_is_not_a_record) property_which_is_not_a_record)
container = c.Container() container = db.Container()
container.extend([ container.extend([
rt, rt,
rt_record_with_parent, # 1005, dependency rt_record_with_parent, # 1005, dependency
...@@ -123,4 +123,4 @@ def test_container_dependencies_for_deletion(): ...@@ -123,4 +123,4 @@ def test_container_dependencies_for_deletion():
record_with_parent, record_with_parent,
record_with_property_which_is_not_a_record record_with_property_which_is_not_a_record
]) ])
assert c.Container()._test_dependencies_in_container(container) == {2002, 1005} assert db.Container()._test_dependencies_in_container(container) == {2002, 1005}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment