Skip to content
Snippets Groups Projects
Commit d83c3008 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

STY: autopep8'd

parent 009e2c07
No related branches found
No related tags found
2 merge requests!217TST: Make NamedTemporaryFiles Windows-compatible,!212ENH: introduce inheritance of identifiables
Pipeline #59891 passed with warnings
...@@ -45,12 +45,13 @@ from .utils import has_parent ...@@ -45,12 +45,13 @@ from .utils import has_parent
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def _retrieve_RecordType(id=None, name =None): def _retrieve_RecordType(id=None, name=None):
""" """
Retrieve the RecordType from LinkAhead. For mocking purposes. Retrieve the RecordType from LinkAhead. For mocking purposes.
""" """
return db.RecordType(name=name, id=id).retrieve() return db.RecordType(name=name, id=id).retrieve()
def get_children_of_rt(rtname): def get_children_of_rt(rtname):
"""Supply the name of a recordtype. This name and the name of all children RTs are returned in """Supply the name of a recordtype. This name and the name of all children RTs are returned in
a list""" a list"""
...@@ -658,8 +659,7 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter): ...@@ -658,8 +659,7 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter):
return registered[0] return registered[0]
else: else:
return None return None
def _get_registered_for_rt(self, rt: db.RecordType): def _get_registered_for_rt(self, rt: db.RecordType):
""" """
returns the registered identifiable for the given RecordType or the returns the registered identifiable for the given RecordType or the
...@@ -681,9 +681,6 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter): ...@@ -681,9 +681,6 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter):
return registered[0] return registered[0]
else: else:
return None return None
def retrieve_identified_record_for_identifiable(self, identifiable: Identifiable): def retrieve_identified_record_for_identifiable(self, identifiable: Identifiable):
query_string = self.create_query_for_identifiable(identifiable) query_string = self.create_query_for_identifiable(identifiable)
......
...@@ -371,8 +371,9 @@ def test_split_into_inserts_and_updates_with_circ(crawler_mocked_identifiable_re ...@@ -371,8 +371,9 @@ def test_split_into_inserts_and_updates_with_circ(crawler_mocked_identifiable_re
with pytest.raises(RuntimeError): with pytest.raises(RuntimeError):
crawler._split_into_inserts_and_updates(st) crawler._split_into_inserts_and_updates(st)
@patch("caoscrawler.identifiable_adapters._retrieve_RecordType",
new=Mock(side_effect=lambda id, name: db.RecordType(id=id,name=name))) @patch("caoscrawler.identifiable_adapters._retrieve_RecordType",
new=Mock(side_effect=lambda id, name: db.RecordType(id=id, name=name)))
def test_split_into_inserts_and_updates_with_complex(crawler_mocked_identifiable_retrieve): def test_split_into_inserts_and_updates_with_complex(crawler_mocked_identifiable_retrieve):
crawler = crawler_mocked_identifiable_retrieve crawler = crawler_mocked_identifiable_retrieve
# A # A
...@@ -400,8 +401,9 @@ def test_split_into_inserts_and_updates_with_complex(crawler_mocked_identifiable ...@@ -400,8 +401,9 @@ 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 # TODO write test where the unresoled entity is not part of the identifiable
@patch("caoscrawler.identifiable_adapters._retrieve_RecordType",
new=Mock(side_effect=lambda id, name: db.RecordType(id=id,name=name))) @patch("caoscrawler.identifiable_adapters._retrieve_RecordType",
new=Mock(side_effect=lambda id, name: db.RecordType(id=id, name=name)))
@patch("caoscrawler.crawl.cached_get_entity_by", @patch("caoscrawler.crawl.cached_get_entity_by",
new=Mock(side_effect=mock_get_entity_by)) new=Mock(side_effect=mock_get_entity_by))
@patch("caoscrawler.identifiable_adapters.cached_query", @patch("caoscrawler.identifiable_adapters.cached_query",
...@@ -584,8 +586,9 @@ def test_split_into_inserts_and_updates_diff_backref(crawler_mocked_for_backref_ ...@@ -584,8 +586,9 @@ def test_split_into_inserts_and_updates_diff_backref(crawler_mocked_for_backref_
assert len(update) == 2 assert len(update) == 2
assert len(insert) == 1 assert len(insert) == 1
@patch("caoscrawler.identifiable_adapters._retrieve_RecordType",
new=Mock(side_effect=lambda id, name: db.RecordType(id=id,name=name))) @patch("caoscrawler.identifiable_adapters._retrieve_RecordType",
new=Mock(side_effect=lambda id, name: db.RecordType(id=id, name=name)))
def test_replace_entities_with_ids(): def test_replace_entities_with_ids():
crawler = Crawler() crawler = Crawler()
a = (db.Record().add_parent("B").add_property("A", 12345) a = (db.Record().add_parent("B").add_property("A", 12345)
...@@ -598,8 +601,8 @@ def test_replace_entities_with_ids(): ...@@ -598,8 +601,8 @@ def test_replace_entities_with_ids():
assert a.get_property("C").value == [12345, 233324] assert a.get_property("C").value == [12345, 233324]
@patch("caoscrawler.identifiable_adapters._retrieve_RecordType", @patch("caoscrawler.identifiable_adapters._retrieve_RecordType",
new=Mock(side_effect=lambda id, name: db.RecordType(id=id,name=name))) new=Mock(side_effect=lambda id, name: db.RecordType(id=id, name=name)))
@patch("caoscrawler.crawl.cached_get_entity_by", @patch("caoscrawler.crawl.cached_get_entity_by",
new=Mock(side_effect=mock_get_entity_by)) new=Mock(side_effect=mock_get_entity_by))
@patch("caoscrawler.identifiable_adapters.cached_get_entity_by", @patch("caoscrawler.identifiable_adapters.cached_get_entity_by",
...@@ -625,8 +628,8 @@ def test_synchronization_no_commit(upmock, insmock): ...@@ -625,8 +628,8 @@ def test_synchronization_no_commit(upmock, insmock):
assert len(ups) == 1 assert len(ups) == 1
@patch("caoscrawler.identifiable_adapters._retrieve_RecordType", @patch("caoscrawler.identifiable_adapters._retrieve_RecordType",
new=Mock(side_effect=lambda id, name: db.RecordType(id=id,name=name))) new=Mock(side_effect=lambda id, name: db.RecordType(id=id, name=name)))
@patch("caoscrawler.crawl.cached_get_entity_by", @patch("caoscrawler.crawl.cached_get_entity_by",
new=Mock(side_effect=mock_get_entity_by)) new=Mock(side_effect=mock_get_entity_by))
@patch("caoscrawler.identifiable_adapters.cached_get_entity_by", @patch("caoscrawler.identifiable_adapters.cached_get_entity_by",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment