From 8666d64355ad97b971c1ddb41cc99a6573f2f11a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Fri, 31 Mar 2023 12:38:46 +0200 Subject: [PATCH] Revert "FIX: #41 https://gitlab.com/caosdb/caosdb-crawler/-/issues/41" This reverts commit d721f2c9b45164f504381e1e933a9ef785578209. --- CHANGELOG.md | 1 - src/caoscrawler/identifiable_adapters.py | 4 +--- unittests/test_identifiable_adapters.py | 13 ------------- unittests/test_tool.py | 9 --------- 4 files changed, 1 insertion(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30a9d5ac..1f790368 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed ### - Query generation when there are only backrefs or backrefs and a name -- [#41](https://gitlab.com/caosdb/caosdb-crawler/-/issues/41) ### Security ### diff --git a/src/caoscrawler/identifiable_adapters.py b/src/caoscrawler/identifiable_adapters.py index b276f96f..eb9333f7 100644 --- a/src/caoscrawler/identifiable_adapters.py +++ b/src/caoscrawler/identifiable_adapters.py @@ -193,14 +193,12 @@ class IdentifiableAdapter(metaclass=ABCMeta): property_name_list_B = [] identifiable_props = {} identifiable_backrefs = [] - name_is_identifying_property = False if registered_identifiable is not None: # fill the values: for prop in registered_identifiable.properties: if prop.name == "name": # The name can be an identifiable, but it isn't a property - name_is_identifying_property = True continue # problem: what happens with multi properties? # case A: in the registered identifiable @@ -248,7 +246,7 @@ class IdentifiableAdapter(metaclass=ABCMeta): record_id=record.id, record_type=(registered_identifiable.parents[0].name if registered_identifiable else None), - name=record.name if name_is_identifying_property else None, + name=record.name, properties=identifiable_props, path=record.path, backrefs=identifiable_backrefs diff --git a/unittests/test_identifiable_adapters.py b/unittests/test_identifiable_adapters.py index 414e5572..894d476d 100644 --- a/unittests/test_identifiable_adapters.py +++ b/unittests/test_identifiable_adapters.py @@ -111,19 +111,6 @@ def test_load_from_yaml_file(): assert project_i.get_property("title") is not None -def test_non_default_name(): - ident = CaosDBIdentifiableAdapter() - ident.register_identifiable( - "Person", db.RecordType() - .add_parent(name="Person") - .add_property(name="last_name")) - identifiable = ident.get_identifiable(db.Record(name="don't touch it") - .add_parent("Person") - .add_property(name="last_name", value='Tom') - ) - assert identifiable.name is None - - def test_convert_value(): # test that string representation of objects stay unchanged. No stripping or so. class A(): diff --git a/unittests/test_tool.py b/unittests/test_tool.py index db708d20..b88720f4 100755 --- a/unittests/test_tool.py +++ b/unittests/test_tool.py @@ -395,7 +395,6 @@ def crawler_mocked_identifiable_retrieve(crawler): return crawler -@pytest.mark.xfail def test_split_into_inserts_and_updates_single(crawler_mocked_identifiable_retrieve): crawler = crawler_mocked_identifiable_retrieve[0] identlist = [Identifiable(name="A", record_type="C"), Identifiable(name="B", record_type="C")] @@ -421,7 +420,6 @@ def test_split_into_inserts_and_updates_single(crawler_mocked_identifiable_retri crawler.identifiableAdapter.retrieve_identified_record_for_identifiable.assert_called() -@pytest.mark.xfail def test_split_into_inserts_and_updates_with_duplicate(crawler_mocked_identifiable_retrieve): crawler = crawler_mocked_identifiable_retrieve[0] a = db.Record(name="A").add_parent("C") @@ -440,7 +438,6 @@ def test_split_into_inserts_and_updates_with_duplicate(crawler_mocked_identifiab crawler.identifiableAdapter.retrieve_identified_record_for_identifiable.assert_called() -@pytest.mark.xfail def test_split_into_inserts_and_updates_with_ref(crawler_mocked_identifiable_retrieve): crawler = crawler_mocked_identifiable_retrieve[0] # try it with a reference @@ -468,7 +465,6 @@ def test_split_into_inserts_and_updates_with_circ(crawler): # TODO this does not seem to be complete! -@pytest.mark.xfail def test_split_into_inserts_and_updates_with_complex(crawler_mocked_identifiable_retrieve): crawler = crawler_mocked_identifiable_retrieve[0] # A @@ -496,7 +492,6 @@ def test_split_into_inserts_and_updates_with_complex(crawler_mocked_identifiable # TODO write test where the unresoled entity is not part of the identifiable -@pytest.mark.xfail def test_split_into_inserts_and_updates_with_copy_attr(crawler_mocked_identifiable_retrieve): crawler = crawler_mocked_identifiable_retrieve[0] # assume identifiable is only the name @@ -514,7 +509,6 @@ def test_split_into_inserts_and_updates_with_copy_attr(crawler_mocked_identifiab crawler.identifiableAdapter.retrieve_identified_record_for_identifiable.assert_called() -@pytest.mark.xfail def test_has_missing_object_in_references(crawler): # Simulate remote server content by using the names to identify records # There are only two known Records with name A and B @@ -819,7 +813,6 @@ def test_validation_error_print(caplog): caplog.clear() -@pytest.mark.xfail def test_split_into_inserts_and_updates_backref(crawler_mocked_for_backref_test): crawler = crawler_mocked_for_backref_test[0] identlist = [Identifiable(name="A", record_type="BR"), @@ -854,7 +847,6 @@ def test_split_into_inserts_and_updates_backref(crawler_mocked_for_backref_test) assert insert[0].name == "B" -@pytest.mark.xfail def test_split_into_inserts_and_updates_mult_backref(crawler_mocked_for_backref_test): # test whether multiple references of the same record type are correctly used crawler = crawler_mocked_for_backref_test[0] @@ -875,7 +867,6 @@ def test_split_into_inserts_and_updates_mult_backref(crawler_mocked_for_backref_ assert len(insert) == 2 -@pytest.mark.xfail def test_split_into_inserts_and_updates_diff_backref(crawler_mocked_for_backref_test): # test whether multiple references of the different record types are correctly used crawler = crawler_mocked_for_backref_test[0] -- GitLab