Commit 2f7e09be authored by Bogdan's avatar Bogdan

Exception Handling for tests 2

parent cba246df
import unittest try:
import sys import unittest
for path in ['../', './']: import sys
for path in ['../', './']:
sys.path.insert(1, path) sys.path.insert(1, path)
# python -m unittest discover # python -m unittest discover
from db.entities import Cluster from db.entities import Cluster
from datetime import date, datetime from datetime import date, datetime
import json import json
class TestCluster(unittest.TestCase): class TestCluster(unittest.TestCase):
def test_init_Cluster(self): def test_init_Cluster(self):
try: try:
c = Cluster('debug', 'debug-table1', 'layer1', 1, [1, 2, 3]) c = Cluster('debug', 'debug-table1', 'layer1', 1, [1, 2, 3])
...@@ -22,5 +23,8 @@ class TestCluster(unittest.TestCase): ...@@ -22,5 +23,8 @@ class TestCluster(unittest.TestCase):
except Exception as e: except Exception as e:
print(e) print(e)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
except Exception as e:
print ("Exception found:")
print (e)
import unittest try:
import sys import unittest
for path in ['../', './']: import sys
for path in ['../', './']:
sys.path.insert(1, path) sys.path.insert(1, path)
# python -m unittest discover # python -m unittest discover
from processing.clustering import ClusterResultConverter, ClusterResult from processing.clustering import ClusterResultConverter, ClusterResult
from typing import List, Dict, Any from typing import List, Dict, Any
class TestClusterResult(unittest.TestCase): class TestClusterResult(unittest.TestCase):
converter:ClusterResultConverter = None converter:ClusterResultConverter = None
def setUp(self): def setUp(self):
...@@ -99,5 +100,8 @@ class TestClusterResult(unittest.TestCase): ...@@ -99,5 +100,8 @@ class TestClusterResult(unittest.TestCase):
} }
#endregion helper methods #endregion helper methods
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
except Exception as e:
print ("Exception found:")
print (e)
\ No newline at end of file
import unittest
import sys try:
for path in ['../', './']: import unittest
import sys
for path in ['../', './']:
sys.path.insert(1, path) sys.path.insert(1, path)
# python -m unittest discover
from processing.clustering import Clusterer, ClusterResult
import numpy as np
from typing import List, Dict, Any
class TestClusterer(unittest.TestCase): # python -m unittest discover
from processing.clustering import Clusterer, ClusterResult
import numpy as np
from typing import List, Dict, Any
class TestClusterer(unittest.TestCase):
clusterer:Clusterer = None clusterer:Clusterer = None
def setUp(self): def setUp(self):
...@@ -190,5 +193,8 @@ class TestClusterer(unittest.TestCase): ...@@ -190,5 +193,8 @@ class TestClusterer(unittest.TestCase):
#endregion helper methods #endregion helper methods
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
except Exception as e:
print ("Exception found:")
print (e)
import unittest try:
import unittest
import sys import sys
for path in ['../', './', '../../../modules/', '../../../../modules']: for path in ['../', './', '../../../modules/', '../../../../modules']:
sys.path.insert(1, path) sys.path.insert(1, path)
from db.entities.connected_node import NodeC from db.entities.connected_node import NodeC
from db.entities.connected_cluster import ClusterC from db.entities.connected_cluster import ClusterC
from db.entities.connected_layer import LayerC from db.entities.connected_layer import LayerC
import math import math
import datetime import datetime
from typing import Dict from typing import Dict
from typing import Dict from typing import Dict
from processing.similarityFiles.dataInput import * from processing.similarityFiles.dataInput import *
from processing.similarityFiles.calculateWeights import * from processing.similarityFiles.calculateWeights import *
from processing.similarityFiles.calculateSimilarity import * from processing.similarityFiles.calculateSimilarity import *
from processing.similarityFiles.miscFunctions import * from processing.similarityFiles.miscFunctions import *
import json import json
class TestSimilarity(unittest.TestCase): class TestSimilarity(unittest.TestCase):
'''Tests the similarity calculation which works without object orientation.''' '''Tests the similarity calculation which works without object orientation.'''
def test_integration_similarityCalculation(self): def test_integration_similarityCalculation(self):
...@@ -67,7 +68,7 @@ class TestSimilarity(unittest.TestCase): ...@@ -67,7 +68,7 @@ class TestSimilarity(unittest.TestCase):
def getTestLocationLayerData(): def getTestLocationLayerData():
inputLayerLocation = [ inputLayerLocation = [
{ {
"cluster_label": 1, "cluster_label": 1,
...@@ -198,7 +199,7 @@ def getTestLocationLayerData(): ...@@ -198,7 +199,7 @@ def getTestLocationLayerData():
] ]
return inputLayerLocation return inputLayerLocation
def getTestTimeLayerData(): def getTestTimeLayerData():
inputLayerTime = [ inputLayerTime = [
{ {
"cluster_label": 4, "cluster_label": 4,
...@@ -297,7 +298,7 @@ def getTestTimeLayerData(): ...@@ -297,7 +298,7 @@ def getTestTimeLayerData():
] ]
return inputLayerTime return inputLayerTime
def getTestPriceLayerData(): def getTestPriceLayerData():
inputLayerPrice = [ inputLayerPrice = [
{ {
"cluster_label": 6, "cluster_label": 6,
...@@ -397,5 +398,8 @@ def getTestPriceLayerData(): ...@@ -397,5 +398,8 @@ def getTestPriceLayerData():
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
except Exception as e:
print ("Exception found:")
print (e)
\ No newline at end of file
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