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

MAINT: minor changes and fixes

parent de14c855
Branches
Tags
1 merge request!53Release 0.1
1. Clear database 1. Clear database (see clear_database.py)
2. Insert model 2. Insert model (see insert_model.py)
3. Run test.py 3. Run test.py
...@@ -80,9 +80,6 @@ Report: ...@@ -80,9 +80,6 @@ Report:
- Publication - Publication
hdf5File: hdf5File:
datatype: REFERENCE datatype: REFERENCE
extern:
- TestRT1
- TestP1
Measurement: Measurement:
recommended_properties: recommended_properties:
date: date:
...@@ -300,8 +300,7 @@ class Crawler(object): ...@@ -300,8 +300,7 @@ class Crawler(object):
# information # information
# Update an (local) identified record that will be inserted # Update an (local) identified record that will be inserted
newrecord = self.get_identified_record_from_local_cache(record) newrecord = self.get_identified_record_from_local_cache(record)
self.copy_attributes( self.copy_attributes(fro=record, to=newrecord)
fro=record, to=newrecord)
# Bend references to the other object # Bend references to the other object
# TODO refactor this # TODO refactor this
for el in flat + to_be_inserted + to_be_updated: for el in flat + to_be_inserted + to_be_updated:
...@@ -333,7 +332,7 @@ class Crawler(object): ...@@ -333,7 +332,7 @@ class Crawler(object):
record.id = identified_record.id record.id = identified_record.id
to_be_updated.append(record) to_be_updated.append(record)
# TODO think this through # TODO think this through
# self.add_identified_record_to_local_cache(record) self.add_identified_record_to_local_cache(record)
del flat[i] del flat[i]
resolved_references = True resolved_references = True
...@@ -391,7 +390,7 @@ class Crawler(object): ...@@ -391,7 +390,7 @@ class Crawler(object):
attr_val = comp[0]["properties"][key][attribute] attr_val = comp[0]["properties"][key][attribute]
other_attr_val = (comp[1]["properties"][key][attribute] other_attr_val = (comp[1]["properties"][key][attribute]
if attribute in comp[1]["properties"][key] else None) if attribute in comp[1]["properties"][key] else None)
if attr_val is not None and atrr_val != other_attr_val: if attr_val is not None and attr_val != other_attr_val:
identical = False identical = False
break break
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
from datetime import datetime from datetime import datetime
import caosdb as db import caosdb as db
from abc import abstractmethod from abc import abstractmethod
from .utils import get_value, has_parent from .utils import has_parent
from caosdb.common.datatype import is_reference from caosdb.common.datatype import is_reference
from .utils import has_parent from .utils import has_parent
......
...@@ -31,6 +31,7 @@ from newcrawler.converters import Converter ...@@ -31,6 +31,7 @@ from newcrawler.converters import Converter
from newcrawler.stores import GeneralStore from newcrawler.stores import GeneralStore
from newcrawler.converters import MarkdownFileConverter from newcrawler.converters import MarkdownFileConverter
from newcrawler.structure_elements import Directory from newcrawler.structure_elements import Directory
from newcrawler.structure_elements import File, DictTextElement, DictListElement
from test_tool import rfp from test_tool import rfp
......
...@@ -40,6 +40,7 @@ def crawler(): ...@@ -40,6 +40,7 @@ def crawler():
rfp("scifolder_cfood.yml")) rfp("scifolder_cfood.yml"))
return crawler return crawler
@pytest.fixture @pytest.fixture
def ident(crawler): def ident(crawler):
ident = LocalStorageIdentifiableAdapter() ident = LocalStorageIdentifiableAdapter()
...@@ -352,13 +353,13 @@ def test_split_into_inserts_and_updates_single(mock_retrieve): ...@@ -352,13 +353,13 @@ def test_split_into_inserts_and_updates_single(mock_retrieve):
def test_split_into_inserts_and_updates_with_duplicate(mock_retrieve): def test_split_into_inserts_and_updates_with_duplicate(mock_retrieve):
crawler = mock_retrieve crawler = mock_retrieve
# try it with a reference
a = db.Record(name="A").add_parent("C") a = db.Record(name="A").add_parent("C")
b = db.Record(name="B").add_parent("C") b = db.Record(name="B").add_parent("C")
b.add_property("A", a) b.add_property("A", a)
# This is identical to a and should be removed
c = db.Record(name="A").add_parent("C") c = db.Record(name="A").add_parent("C")
entlist = [a, b, c] entlist = [a, b, c]
insert, update = crawler.split_into_inserts_and_updates(entlist) insert, update = crawler.split_into_inserts_and_updates(deepcopy(entlist))
assert len(insert) == 1 assert len(insert) == 1
assert insert[0].name == "B" assert insert[0].name == "B"
assert len(update) == 1 assert len(update) == 1
...@@ -412,6 +413,7 @@ def test_split_into_inserts_and_updates_with_complex(mock_retrieve): ...@@ -412,6 +413,7 @@ def test_split_into_inserts_and_updates_with_complex(mock_retrieve):
# TODO write test where the unresoled entity is not part of the 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(mock_retrieve): def test_split_into_inserts_and_updates_with_copy_attr(mock_retrieve):
crawler = mock_retrieve crawler = mock_retrieve
# assume identifiable is only the name # assume identifiable is only the name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment