From b91ab1c6996745caef3ef8f13d0a834b3272a3b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Mon, 27 Feb 2023 11:13:21 +0100 Subject: [PATCH] TST: add unittest for create_entity_summary --- src/caoscrawler/crawl.py | 2 +- unittests/test_tool.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py index 422ea963..18d2fcb3 100644 --- a/src/caoscrawler/crawl.py +++ b/src/caoscrawler/crawl.py @@ -1058,7 +1058,7 @@ class Crawler(object): for el in entities: for pp in el.parents: if pp.name not in parents: - parents[pp.name] = [] + parents[pp.name] = [el] else: parents[pp.name].append(el) output = "" diff --git a/unittests/test_tool.py b/unittests/test_tool.py index 4ac2b457..ca9d074e 100755 --- a/unittests/test_tool.py +++ b/unittests/test_tool.py @@ -967,3 +967,20 @@ def test_split_restricted_path(): assert ["el"] == split_restricted_path("/el") assert ["el"] == split_restricted_path("/el/") assert ["el", "el"] == split_restricted_path("/el/el") + + +def test_create_entity_summary(): + assert "" == Crawler.create_entity_summary([]).strip() + + entities = [ + db.Record(id=1).add_parent("A"), + db.Record(id=4, name='a').add_parent("B"), + db.Record(id=5).add_parent("A"), + db.Record(id=6, name='b').add_parent("B"), + ] + text = Crawler.create_entity_summary(entities).strip() + assert 'a' in text + assert 'b' in text + assert 'A:' in text + assert 'B:' in text + assert "<a href='/Entity/4'>a</a>, <a href='/Entity/6'>b</a>" in text -- GitLab