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

TST: add a failing test

parent d7d81141
No related branches found
No related tags found
2 merge requests!160STY: styling,!157FIX Yet another corner case of referencing resolution resolved
Pipeline #47722 failed
...@@ -38,6 +38,7 @@ import linkahead as db ...@@ -38,6 +38,7 @@ import linkahead as db
import linkahead.common.models as dbmodels import linkahead.common.models as dbmodels
import pytest import pytest
import yaml import yaml
from caosadvancedtools.models.parser import parse_model_from_string
from caoscrawler.crawl import (Crawler, SecurityMode, TreatedRecordLookUp, from caoscrawler.crawl import (Crawler, SecurityMode, TreatedRecordLookUp,
_treat_deprecated_prefix, crawler_main, _treat_deprecated_prefix, crawler_main,
split_restricted_path) split_restricted_path)
...@@ -52,7 +53,6 @@ from caoscrawler.stores import GeneralStore, RecordStore ...@@ -52,7 +53,6 @@ from caoscrawler.stores import GeneralStore, RecordStore
from caoscrawler.structure_elements import (DictElement, DictListElement, from caoscrawler.structure_elements import (DictElement, DictListElement,
DictTextElement, File) DictTextElement, File)
from linkahead.apiutils import compare_entities from linkahead.apiutils import compare_entities
from caosadvancedtools.models.parser import parse_model_from_string
from linkahead.cached import cache_clear from linkahead.cached import cache_clear
from linkahead.exceptions import EmptyUniqueQueryError from linkahead.exceptions import EmptyUniqueQueryError
from pytest import raises from pytest import raises
...@@ -1144,3 +1144,20 @@ def test_treated_record_lookup(): ...@@ -1144,3 +1144,20 @@ def test_treated_record_lookup():
fi2 = db.File(path='b') fi2 = db.File(path='b')
trlu.add(fi2) trlu.add(fi2)
assert trlu.get_any(db.File(path='b'), Identifiable(name='c')) is fi2 assert trlu.get_any(db.File(path='b'), Identifiable(name='c')) is fi2
def test_merge_entity_with_identifying_reference(crawler_mocked_identifiable_retrieve):
# When one python object representing a record is merged into another python object
# representing the same record, the former object can be forgotten and references from it to
# other records must not play a role
crawler = crawler_mocked_identifiable_retrieve
crawler.identifiableAdapter.get_registered_identifiable = Mock(
side_effect=lambda x: db.Record().add_parent('C').add_property(name='name') if
x.parents[0].name == "C" else
db.Record().add_parent('D').add_property(name='is_referenced_by', value="*")
)
a = db.Record(name='a').add_parent("D")
b = db.Record(name='b').add_parent("C")
c = db.Record(name='b').add_parent("C").add_property(name="C", value=a)
flat = [a, c, b]
_, _ = crawler.split_into_inserts_and_updates(flat)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment