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

TST: enhance doc and fix test

parent c93b00c2
No related branches found
No related tags found
2 merge requests!123REL: Release v0.6.0,!117ENH: detect circular dependencies
Pipeline #37039 failed
...@@ -641,7 +641,7 @@ class Crawler(object): ...@@ -641,7 +641,7 @@ class Crawler(object):
+ str(self.compact_entity_list_representation(flat))) + str(self.compact_entity_list_representation(flat)))
else: else:
logger.error("Found circular dependency (Note that this might include references " logger.error("Found circular dependency (Note that this might include references "
"that are not identifying properties: " "that are not identifying properties): "
+ self.compact_entity_list_representation(circle)) + self.compact_entity_list_representation(circle))
raise RuntimeError( raise RuntimeError(
f"Could not finish split_into_inserts_and_updates. Circular dependency: " f"Could not finish split_into_inserts_and_updates. Circular dependency: "
...@@ -681,7 +681,7 @@ class Crawler(object): ...@@ -681,7 +681,7 @@ class Crawler(object):
""" """
Detects whether there are circular references in the given entity list and returns a list Detects whether there are circular references in the given entity list and returns a list
where the entities are ordered according to the chain of references (and only the entities where the entities are ordered according to the chain of references (and only the entities
contained in the circle are included. contained in the circle are included. Returns None if no circular dependency is found.
TODO: for the sake of detecting problems for split_into_inserts_and_updates we should only TODO: for the sake of detecting problems for split_into_inserts_and_updates we should only
consider references that are identifying properties. consider references that are identifying properties.
......
...@@ -874,8 +874,7 @@ def test_detect_circular_dependency(crawler_mocked_identifiable_retrieve, caplog ...@@ -874,8 +874,7 @@ def test_detect_circular_dependency(crawler_mocked_identifiable_retrieve, caplog
circle = Crawler.detect_circular_dependency(flat) circle = Crawler.detect_circular_dependency(flat)
assert [id(el) for el in circle] == [id(el) for el in [a, c, b, a]] assert [id(el) for el in circle] == [id(el) for el in [a, c, b, a]]
with raises(Exception): assert detect_circular_dependency([d]) is None
detect_circular_dependency([d])
with raises(RuntimeError): with raises(RuntimeError):
_, _ = crawler.split_into_inserts_and_updates(flat) _, _ = crawler.split_into_inserts_and_updates(flat)
caplog.set_level(logging.ERROR, logger="caoscrawler.converters") caplog.set_level(logging.ERROR, logger="caoscrawler.converters")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment