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

Merge branch 'f-correct-labels' into 'dev'

Correct labels in yaml model parser

See merge request !119
parents c6b1da47 865aa265
No related branches found
No related tags found
2 merge requests!128MNT: Added a warning when column metadata is not configured, and a better...,!119Correct labels in yaml model parser
Pipeline #57596 passed
...@@ -130,6 +130,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -130,6 +130,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `TableImporter.check_missing` in case of array-valued fields in table * `TableImporter.check_missing` in case of array-valued fields in table
* YAML model parser has better description handling. * YAML model parser has better description handling.
* YAML model parser shows "LinkAhead" and "the yaml file" in its comparison display
instead of "old" and "new".
### Documentation ### ### Documentation ###
......
...@@ -146,7 +146,9 @@ class DataModel(dict): ...@@ -146,7 +146,9 @@ class DataModel(dict):
query = db.Query(f"FIND ENTITY with id={ent.id}") query = db.Query(f"FIND ENTITY with id={ent.id}")
ref = query.execute(unique=True) ref = query.execute(unique=True)
diff = (describe_diff(*compare_entities(ent, ref), diff = (describe_diff(*compare_entities(ent, ref),
name=ent.name)) name=ent.name,
label_e0="version from the yaml file",
label_e1="version from LinkAhead"))
if diff != "": if diff != "":
if verbose: if verbose:
......
...@@ -21,8 +21,11 @@ from datetime import date ...@@ -21,8 +21,11 @@ from datetime import date
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
from pytest import raises, mark from pytest import raises, mark
from unittest.mock import Mock
import linkahead as db import linkahead as db
import caosadvancedtools
from caosadvancedtools.models.parser import (TwiceDefinedException, from caosadvancedtools.models.parser import (TwiceDefinedException,
YamlDefinitionError, YamlDefinitionError,
parse_model_from_string, parse_model_from_string,
...@@ -644,6 +647,46 @@ RT2: ...@@ -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(): def test_setting_values():
model = parse_model_from_string(""" model = parse_model_from_string("""
parameter: parameter:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment