Skip to content
Snippets Groups Projects
Verified Commit 0c6a2f79 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

FIX: Better handling of unidentified entities.

parent 735ca8bc
No related branches found
No related tags found
2 merge requests!160STY: styling,!155Mitigation of server problem with long strings as POV values
Pipeline #47609 passed
......@@ -613,7 +613,8 @@ class Crawler(object):
"""
try:
merge_entities(
newrecord, record, merge_references_with_empty_diffs=False, merge_id_with_resolved_entity=True)
newrecord, record, merge_references_with_empty_diffs=False,
merge_id_with_resolved_entity=True)
except EntityMergeConflictError:
_treat_merge_error_of(newrecord, record)
# We cannot merge but it is none of the clear case where merge is
......@@ -637,6 +638,8 @@ class Crawler(object):
"""
registered_identifiable = self.identifiableAdapter.get_registered_identifiable(record)
if registered_identifiable is None:
return False
refs = self.identifiableAdapter.get_identifying_referencing_entities(referencing_entities,
registered_identifiable)
if any([el is None for el in refs]):
......
......@@ -34,8 +34,8 @@ from pathlib import Path
from unittest.mock import MagicMock, Mock, patch
import caoscrawler
import caosdb as db
import caosdb.common.models as dbmodels
import linkahead as db
import linkahead.common.models as dbmodels
import pytest
import yaml
from caoscrawler.crawl import (Crawler, SecurityMode, TreatedRecordLookUp,
......@@ -216,6 +216,13 @@ def test_split_into_inserts_and_updates_trivial():
crawler.split_into_inserts_and_updates([])
def test_split_into_inserts_and_updates_unidentified():
crawler = Crawler()
with raises(ValueError) as err:
crawler.split_into_inserts_and_updates([db.Record(name="recname").add_parent("someparent")])
assert str(err.value).startswith("There is no identifying information.")
def basic_retrieve_by_name_mock_up(rec, referencing_entities=None, known=None):
""" returns a stored Record if rec.name is an existing key, None otherwise """
if rec.name in known:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment