Commit cfa062b9 authored by Alexander Lercher's avatar Alexander Lercher

Partially fixed tests

parent b2381df0
# add modules folder to interpreter path # add modules folder to interpreter path
import sys import sys
import os import os
modules_paths = ['../', '../../../../modules/'] modules_paths = ['./', '../', '../../../../modules/', '../../../modules/']
for path in modules_paths: for path in modules_paths:
if os.path.exists(path): if os.path.exists(path):
sys.path.insert(1, path) sys.path.insert(1, path)
import unittest
import manage_sys_paths
import json
from initialdemo.HyperGraph import HyperGraph
class Test_HyperGraph(unittest.TestCase):
hypergraph: HyperGraph = None
def setUp(self):
self.hypergraph = HyperGraph()
def test_removeDuplicates_noDupOrdered_sameContent(self):
list_ = [[1,2,3]]
set_ = self.hypergraph.remove_duplicates(list_)
self.assertEqual(list_, set_)
def test_removeDuplicates_oneDupOrdered_removed(self):
list_ = [[1,2,3,3]]
set_ = self.hypergraph.remove_duplicates(list_)
self.assertEqual([[1,2,3]], set_)
def test_removeDuplicates_multDupOrdered_allRemoved(self):
list_ = [[1,1,2,3,3,4]]
set_ = self.hypergraph.remove_duplicates(list_)
self.assertEqual([[1,2,3,4]], set_)
def test_removeDuplicates_noDupUnordered_sameContent(self):
list_ = [[1,2,3,5,9,4,30,15]]
set_ = self.hypergraph.remove_duplicates(list_)
self.assertEqual(list_, set_)
def test_removeDuplicates_oneDupUnordered_removed(self):
list_ = [[1,2,3,5,9,4,30,5,15]]
set_ = self.hypergraph.remove_duplicates(list_)
self.assertEqual([[1,2,3,5,9,4,30,15]], set_)
def test_removeDuplicates_multDupUnordered_allRemoved(self):
list_ = [[1,2,5,3,1,70,25,-1,7,-1]]
set_ = self.hypergraph.remove_duplicates(list_)
self.assertEqual([[1,2,5,3,70,25,-1,7]], set_)
def test_removeDuplicates_oneDupOrderedMultDim_removed(self):
list_ = [[1,1,2],[2,2,3]]
set_ = self.hypergraph.remove_duplicates(list_)
self.assertEqual([[1,2],[2,3]], set_)
def test_removeDuplicates_multDupOrderedMultDim_allRemoved(self):
list_ = [[1,1,2,3,3],[2,2,3,4,4,5]]
set_ = self.hypergraph.remove_duplicates(list_)
self.assertEqual([[1,2,3],[2,3,4,5]], set_)
def test_removeDuplicates_multDupUnorderedMultDim_allRemoved(self):
list_ = [[1,2,5,2,7,3],[-10,5,3,20,-10,-7]]
set_ = self.hypergraph.remove_duplicates(list_)
self.assertEqual([[1,2,5,7,3],[-10,5,3,20,-7]], set_)
def test_removeDuplicates_multDupUnorderedMultDim2_allRemoved(self):
list_ = [[1,2,5,2,7,3],[-10,5,3,20,-10,-7],[1,2]]
set_ = self.hypergraph.remove_duplicates(list_)
self.assertEqual([[1,2,5,7,3],[-10,5,3,20,-7],[1,2]], set_)
def test_removeDuplicates_multDupUnorderedTripleDim_noDupRemoved(self):
list_ = [[[1,2,5,2,7,3],[-10,5,3,20,-10,-7],[1,2]]]
set_ = self.hypergraph.remove_duplicates(list_)
self.assertEqual(list_, set_)
if __name__ == '__main__':
unittest.main()
\ No newline at end of file
import sys
import os
modules_path = '../../../modules/'
if os.path.exists(modules_path):
sys.path.insert(1, modules_path)
import unittest import unittest
import manage_sys_paths import manage_sys_paths
import json import json
...@@ -17,7 +11,7 @@ class DummyMongoRepo: ...@@ -17,7 +11,7 @@ class DummyMongoRepo:
def insert_trace(self, trace): def insert_trace(self, trace):
self.last_trace = trace self.last_trace = trace
class Test_HyperGraph(unittest.TestCase): class Test_Pipeline(unittest.TestCase):
handler = None handler = None
repo = None repo = None
msg_sender = None msg_sender = None
...@@ -45,7 +39,6 @@ class Test_HyperGraph(unittest.TestCase): ...@@ -45,7 +39,6 @@ class Test_HyperGraph(unittest.TestCase):
} }
def testTraceProcessing(self): def testTraceProcessing(self):
print("START")
msg = self._buildTraceMessage() msg = self._buildTraceMessage()
self.handler.handle_new_trace(msg["content"]) self.handler.handle_new_trace(msg["content"])
......
# add modules folder to interpreter path
import sys
import os
modules_paths = ['./', '../', '../../../modules/']
for path in modules_paths:
if os.path.exists(path):
sys.path.insert(1, path)
import unittest import unittest
# import manage_sys_paths
from db.entities.layer_adapter import LayerAdapter from db.entities.layer_adapter import LayerAdapter
class Layer_Adapter_Test(unittest.TestCase): class Test_Layer_Adapter(unittest.TestCase):
def test_valid_adapter(self): def test_valid_adapter(self):
adapter1 = LayerAdapter("layer1", {"a":"b", "c":"d"}, ["a"]) adapter1 = LayerAdapter("layer1", {"a":"b", "c":"d"}, ["a"])
print(adapter1.to_serializable_dict) print(adapter1.to_serializable_dict)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment