diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py index 422ea9639c4bc496f46fc668ace6cc9754ece305..18d2fcb368935abd6cd51acdc9f05fbc27fd46e0 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 4ac2b4577fbeea6f4bdf291c48ddaf0fa418b2a5..ca9d074e4a65b83d02347c2f7773e8a9b963886c 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