From 159c3ae460431840d4fcfeaec29469b2c465dd39 Mon Sep 17 00:00:00 2001 From: Malte Schokolowski <baw8441@uni-hamburg.de> Date: Tue, 21 Dec 2021 14:08:25 +0100 Subject: [PATCH] bug fixes from desktop --- verarbeitung/test/construct_graph_unittest.py | 21 ++++++++++- verarbeitung/test/update_graph_unittest.py | 36 +++++++++---------- .../update_graph/delete_nodes_edges.py | 1 + verarbeitung/update_graph/update_depth.py | 1 - 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/verarbeitung/test/construct_graph_unittest.py b/verarbeitung/test/construct_graph_unittest.py index 13f201c..328bb43 100644 --- a/verarbeitung/test/construct_graph_unittest.py +++ b/verarbeitung/test/construct_graph_unittest.py @@ -2,9 +2,10 @@ import unittest import sys from pathlib import Path + sys.path.append("../") -from verarbeitung.construct_new_graph.initialize_graph import init_graph_construction +from verarbeitung.construct_new_graph.initialize_graph import init_graph_construction, initialize_nodes_list class ConstructionTest(unittest.TestCase): maxDiff = None @@ -83,6 +84,24 @@ class ConstructionTest(unittest.TestCase): self.assertCountEqual(edges, [['doi_d02','doi_d1'], ['doi_d1','doi_d2']]) + ## Ab hier die Tests für die einzelnen Funktionen ## + + # initialize_graph.py: + + def test_initialize_nodes_list(self): + references_pub_obj_list, citations_pub_obj_list = initialize_nodes_list(['doi_lg_1_i','doi_lg_2_i'], 0, 0, True) + doi_references = keep_only_dois(references_pub_obj_list) + doi_citations = keep_only_dois(citations_pub_obj_list) + self.assertCountEqual(doi_references, []) + self.assertCountEqual(doi_citations, []) + + references_pub_obj_list, citations_pub_obj_list = initialize_nodes_list(['doi_lg_1_i','doi_lg_2_i'], 1, 1, True) + doi_references = keep_only_dois(references_pub_obj_list) + doi_citations = keep_only_dois(citations_pub_obj_list) + self.assertCountEqual(doi_references, ['doi_lg_1_d11','doi_lg_1_d12','doi_lg_2_d11','doi_lg_2_d12']) + self.assertCountEqual(doi_citations, ['doi_lg_1_h11','doi_lg_1_h12','doi_cg_i','doi_lg_2_h11','doi_lg_2_h12']) + + def keep_only_dois(nodes): diff --git a/verarbeitung/test/update_graph_unittest.py b/verarbeitung/test/update_graph_unittest.py index cf8261a..c44de64 100644 --- a/verarbeitung/test/update_graph_unittest.py +++ b/verarbeitung/test/update_graph_unittest.py @@ -13,24 +13,24 @@ from verarbeitung.update_graph.update_graph import update_graph class UpdatingTest(unittest.TestCase): maxDiff = None - # def test_import_from_json(self): - # nodes_old, edges_old = init_graph_construction(['doi_lg_1_i'],2,2,True) - # output_to_json(nodes_old, edges_old, test_var = True) - # nodes_new, edges_new = input_from_json('test_output.json') - # self.assertCountEqual(nodes_old,nodes_new) - # self.assertCountEqual(edges_old, edges_new) - - # def test_deleted_input_dois(self): - # nodes_old_single, edges_old_single = init_graph_construction(['doi_lg_1_i'],2,2,True) - # nodes_old_both, edges_old_both = init_graph_construction(['doi_lg_1_i','doi_lg_2_i'],2,2,True) - # output_to_json(nodes_old_both, edges_old_both, test_var=True) - # nodes_new_single, edges_new_single = update_graph(['doi_lg_1_i'], 'test_output.json', 2, 2, True) - # self.assertCountEqual(nodes_old_single,nodes_new_single) - # self.assertCountEqual(edges_old_single, edges_new_single) - - # nodes_old_single, edges_old_single = init_graph_construction(['doi_cg_i'],3,3,True) - # nodes_old_two, edges_old_two = init_graph_construction(['doi_lg_1_i','doi_cg_i'],3,3,True) - # nodes_old_three, edges_old_three = init_graph_construction(['doi_lg_1_i','doi_lg_2_i','doi_cg_i'],3,3,True) + def test_import_from_json(self): + nodes_old, edges_old = init_graph_construction(['doi_lg_1_i'],2,2,True) + output_to_json(nodes_old, edges_old, test_var = True) + nodes_new, edges_new = input_from_json('test_output.json') + self.assertCountEqual(nodes_old,nodes_new) + self.assertCountEqual(edges_old, edges_new) + + def test_deleted_input_dois(self): + nodes_old_single, edges_old_single = init_graph_construction(['doi_lg_1_i'],2,2,True) + nodes_old_both, edges_old_both = init_graph_construction(['doi_lg_1_i','doi_lg_2_i'],2,2,True) + output_to_json(nodes_old_both, edges_old_both, test_var=True) + nodes_new_single, edges_new_single = update_graph(['doi_lg_1_i'], 'test_output.json', 2, 2, True) + self.assertCountEqual(nodes_old_single,nodes_new_single) + self.assertCountEqual(edges_old_single, edges_new_single) + + nodes_old_single, edges_old_single = init_graph_construction(['doi_cg_i'],3,3,True) + nodes_old_two, edges_old_two = init_graph_construction(['doi_lg_1_i','doi_cg_i'],3,3,True) + nodes_old_three, edges_old_three = init_graph_construction(['doi_lg_1_i','doi_lg_2_i','doi_cg_i'],3,3,True) def test_new_height(self): nodes_height_0, edges_height_0 = init_graph_construction(['doi_lg_1_i'],2,0,True) diff --git a/verarbeitung/update_graph/delete_nodes_edges.py b/verarbeitung/update_graph/delete_nodes_edges.py index 0e4571a..7145fd7 100644 --- a/verarbeitung/update_graph/delete_nodes_edges.py +++ b/verarbeitung/update_graph/delete_nodes_edges.py @@ -91,5 +91,6 @@ def delete_nodes_and_edges(input_list, common_nodes, old_edges_list): search_cit_graph_rec(pub) valid_edges = back_to_valid_edges(old_edges_list, usable_nodes) + return(usable_nodes, valid_edges) \ No newline at end of file diff --git a/verarbeitung/update_graph/update_depth.py b/verarbeitung/update_graph/update_depth.py index 4084973..696a99c 100644 --- a/verarbeitung/update_graph/update_depth.py +++ b/verarbeitung/update_graph/update_depth.py @@ -131,7 +131,6 @@ def update_depth(obj_input_list, input_edges, new_depth, new_height, test_var): back_to_valid_edges(valid_edges, processed_input_list) # adds edges between reference group and citation group of known publications - complete_inner_edges() return(old_depth, old_height) -- GitLab