Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • caosdb/src/caosdb-advanced-user-tools
1 result
Show changes
#!/usr/bin/env python3
# This file is a part of the CaosDB Project.
# This file is a part of the LinkAhead project.
#
# Copyright (C) 2021 IndiScale GmbH <www.indiscale.com>
# Copyright (C) 2021 Henrik tom Wörden <h.tomwoerden@indiscale.com>
......@@ -22,10 +22,10 @@
import unittest
from os import name
import caosdb as db
import linkahead as db
from caosadvancedtools.structure_mapping import (EntityMapping,
collect_existing_structure)
from caosdb.common import datatype
from linkahead.common import datatype
class structureMappingTest(unittest.TestCase):
......
......@@ -2,7 +2,7 @@
# encoding: utf-8
#
# ** header v3.0
# This file is a part of the CaosDB Project.
# This file is a part of the LinkAhead project.
#
# Copyright (C) 2020 IndiScale GmbH
# Copyright (C) 2020 Henrik tom Wörden
......
......@@ -2,7 +2,7 @@
# encoding: utf-8
#
# ** header v3.0
# This file is a part of the CaosDB Project.
# This file is a part of the LinkAhead project.
#
# Copyright (C) 2019 Henrik tom Wörden
#
......@@ -24,9 +24,9 @@ import os
import unittest
from tempfile import NamedTemporaryFile
import caosdb as db
import linkahead as db
import pandas as pd
from caosdb.apiutils import compare_entities
from linkahead.apiutils import compare_entities
from numpy import nan
from caosadvancedtools.table_converter import (from_table, from_tsv, to_table,
......
......@@ -2,7 +2,7 @@
# encoding: utf-8
#
# ** header v3.0
# This file is a part of the CaosDB Project.
# This file is a part of the LinkAhead project.
#
# Copyright (C) 2020 Henrik tom Wörden
#
......@@ -26,7 +26,7 @@ import unittest
from copy import deepcopy
from tempfile import NamedTemporaryFile
import caosdb as db
import linkahead as db
from caosadvancedtools.cache import UpdateCache, get_pretty_xml
......
......@@ -2,7 +2,7 @@
# encoding: utf-8
#
# ** header v3.0
# This file is a part of the CaosDB Project.
# This file is a part of the LinkAhead project.
#
# Copyright (C) 2019 Henrik tom Wörden
#
......@@ -24,12 +24,12 @@ import logging
import unittest
from tempfile import NamedTemporaryFile
import caosdb as db
import linkahead as db
from caosadvancedtools.utils import (check_win_path, get_referenced_files,
string_to_person, create_entity_link)
from caosdb import RecordType, configure_connection, get_config
from caosdb.connection.mockup import MockUpResponse, MockUpServerConnection
from caosdb.exceptions import TransactionError
from linkahead import RecordType, configure_connection, get_config
from linkahead.connection.mockup import MockUpResponse, MockUpServerConnection
from linkahead.exceptions import TransactionError
class BaseMockUpTest(unittest.TestCase):
......
# This file is a part of the CaosDB Project.
# This file is a part of the LinkAhead project.
#
# Copyright (C) 2023 IndiScale GmbH <info@indiscale.com>
# Copyright (C) 2023 Daniel Hornung <d.hornung@indiscale.com>
......@@ -21,8 +21,11 @@ from datetime import date
from tempfile import NamedTemporaryFile
from pytest import raises, mark
from unittest.mock import Mock
import linkahead as db
import caosadvancedtools
from caosadvancedtools.models.parser import (TwiceDefinedException,
YamlDefinitionError,
parse_model_from_string,
......@@ -644,6 +647,46 @@ RT2:
}"""
def test_sync_output(capfd):
model = parse_model_from_string("""
RT:
obligatory_properties:
identifier:
datatype: TEXT
""")
existing_entities = [db.RecordType(name="RT", id=25).add_property(name="identifier",
datatype="INTEGER",
importance="OBLIGATORY",
id=24),
db.Property(name="identifier", datatype="INTEGER", id=24)]
def get_existing_entities(ent_cont):
return existing_entities
class MockQuery:
def __init__(self, q):
self.q = q
def execute(self, unique=True):
id = int(self.q.split("=")[1])
for existing_ent in existing_entities:
if existing_ent.id == id:
return existing_ent
return None
model.get_existing_entities = get_existing_entities
caosadvancedtools.models.parser.db.Query = MockQuery
caosadvancedtools.models.parser.db.Container.update = Mock()
model.sync_data_model(True, True)
assert caosadvancedtools.models.parser.db.Container.update.called
output, err = capfd.readouterr()
print(output)
assert "version from the yaml file: TEXT" in output
assert "version from LinkAhead: INTEGER" in output
def test_setting_values():
model = parse_model_from_string("""
parameter:
......