Skip to content
Snippets Groups Projects
Commit 8b99457a authored by Molkentin, Alina's avatar Molkentin, Alina
Browse files

Unittest Datei hinzugefügt

parent 2ca8d152
No related branches found
No related tags found
1 merge request!7Main
......@@ -63,7 +63,7 @@ def create_graph_structure_citations(pub, search_height, search_height_max):
edges.append([citation.doi_url,pub.doi_url])
# adds only edge if citation already exists
else:
elif [citation.doi_url,pub.doi_url] not in edges:
edges.append([citation.doi_url,pub.doi_url])
......@@ -85,7 +85,7 @@ def create_graph_structure_references(pub, search_depth, search_depth_max):
edges.append([pub.doi_url,reference.doi_url])
# adds only edge if citation already exists
else:
elif [pub.doi_url,reference.doi_url] not in edges:
edges.append([pub.doi_url,reference.doi_url])
......@@ -182,13 +182,20 @@ def process_main(doi_input_list, search_height, search_depth, test_var = False):
output_to_json(nodes,edges)
# only for internal testing
return(nodes,edges)
doi_nodes = []
for node in nodes:
doi_nodes.append(node.doi_url)
return(doi_nodes,edges)
def print_graph(nodes, edges):
print("Knoten:\n")
for node in nodes:
print(node.title, "\n")
print("\n Kanten:\n")
print("\nKanten:\n")
for edge in edges:
print(edge,"\n")
......@@ -201,6 +208,8 @@ def test_cycle():
nodes,edges = process_main(arr,1,1,True)
print(nodes, edges)
print_graph(nodes, edges)
# program test, because there is no connection to the input yet.
......@@ -222,5 +231,8 @@ def test_print():
print_graph(nodes, edges)
#test_print()
test_cycle()
#test_cycle()
print(process_main(['doiz1'],1,1,True))
print(process_main(['doi1'],0,0,True))
\ No newline at end of file
import unittest
from Processing import process_main
class ProcessingTest(unittest.TestCase):
def testCycle(self):
self.assertEqual(process_main(['doiz1'],1,1,True), (['doiz1', 'doiz2'], [['doiz2', 'doiz1'], ['doiz1', 'doiz2']]))
self.assertEqual(process_main(['doiz1'],2,2,True), (['doiz1', 'doiz2'], [['doiz2', 'doiz1'], ['doiz1', 'doiz2']]))
#def testBigCycle(self):
#def testEmptyHeight(self):
#def testEmptyDepth(self):
def testEmptyDepthHeight(self):
self.assertEqual(process_main(['doi1'],0,0,True), (['doi1'], []))
self.assertEqual(process_main(['doi1', 'doi2'],0,0,True), (['doi1','doi2'], [['doi1', 'doi2']]))
self.assertEqual(process_main(['doi1', 'doi2', 'doi3'],0,0,True), (['doi1','doi2', 'doi3'], [['doi3', 'doi1'], ['doi1', 'doi2']]))
#def testInnerEdges(self):
if __name__ == "__main__":
unittest.main()
\ No newline at end of file
File added
No preview for this file type
File added
{"nodes": [{"name": "titlez1", "author": ["contributorz1.1", "contributorz1.2"], "year": "datez1", "journal": "journalz1", "doi": "doiz1", "group": "input"}, {"name": "titlez2", "author": ["contributorz2.1", "contributorz2.2"], "year": "datez2", "journal": "journalz2", "doi": "doiz2", "group": "depth"}], "links": [{"source": "doiz1", "target": "doiz2"}]}
\ No newline at end of file
{"nodes": [{"name": "title1", "author": ["contributor1"], "year": "date1", "journal": "journal1", "doi": "doi1", "group": "input"}, {"name": "title2", "author": ["contributor2"], "year": "date2", "journal": "journal2", "doi": "doi2", "group": "input"}, {"name": "title3", "author": ["contributor3"], "year": "date3", "journal": "journal3", "doi": "doi3", "group": "input"}], "links": [{"source": "doi3", "target": "doi1"}, {"source": "doi1", "target": "doi2"}]}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment