Commit 3d79e088 authored by Bogdan's avatar Bogdan

Error Handling

parent a919d413
...@@ -4,9 +4,10 @@ for path in ['../', './']: ...@@ -4,9 +4,10 @@ for path in ['../', './']:
sys.path.insert(1, path) sys.path.insert(1, path)
try:
class TestCoverage(unittest.TestCase): class TestCoverage(unittest.TestCase):
def test_init_main(self): def test_init_main(self):
try:
# python -m unittest discover # python -m unittest discover
from db.entities import Cluster from db.entities import Cluster
...@@ -34,11 +35,17 @@ class TestCoverage(unittest.TestCase): ...@@ -34,11 +35,17 @@ class TestCoverage(unittest.TestCase):
from env_info import is_running_locally, get_resources_path from env_info import is_running_locally, get_resources_path
from flask import request from flask import request
from flask import redirect from flask import redirect
except:
pass
try:
import main #error when importing main, ModuleNotFoundError: No module named 'security' import main #error when importing main, ModuleNotFoundError: No module named 'security'
#exec(open('main.py').read()) #exec(open('main.py').read())
except:
pass
def test_init_run_clustering(self): def test_init_run_clustering(self):
try:
import sys import sys
import os import os
modules_path = '../../../modules/' modules_path = '../../../modules/'
...@@ -50,10 +57,16 @@ class TestCoverage(unittest.TestCase): ...@@ -50,10 +57,16 @@ class TestCoverage(unittest.TestCase):
from typing import List, Dict, Tuple, Any from typing import List, Dict, Tuple, Any
from db.repository import Repository from db.repository import Repository
from processing.clustering import Clusterer, ClusterResult from processing.clustering import Clusterer, ClusterResult
except:
pass
try:
import run_clustering import run_clustering
except:
pass
def test_init_run_node(self): def test_init_run_node(self):
try:
import sys import sys
import os import os
modules_path = '../../../modules/' modules_path = '../../../modules/'
...@@ -63,17 +76,26 @@ class TestCoverage(unittest.TestCase): ...@@ -63,17 +76,26 @@ class TestCoverage(unittest.TestCase):
import json import json
import urllib3 import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
except:
pass
try:
import processing.fetching.fetching as f import processing.fetching.fetching as f
import run_node_fetching import run_node_fetching
except:
pass
def test_init_run_similarity(self): def test_init_run_similarity(self):
try:
import processing.similarityFiles.similarityMain as SimilarityCalc import processing.similarityFiles.similarityMain as SimilarityCalc
from db.repository import Repository from db.repository import Repository
import run_similarity_calc import run_similarity_calc
except:
pass
def test_init_run_time(self): def test_init_run_time(self):
try:
import sys import sys
import os import os
modules_path = '../../../modules/' modules_path = '../../../modules/'
...@@ -85,9 +107,16 @@ class TestCoverage(unittest.TestCase): ...@@ -85,9 +107,16 @@ class TestCoverage(unittest.TestCase):
from db.repository import Repository from db.repository import Repository
from db.entities import ClusterSet, Cluster, Layer, TimeSlice from db.entities import ClusterSet, Cluster, Layer, TimeSlice
from typing import Tuple, Dict, Any, List from typing import Tuple, Dict, Any, List
except:
pass
try:
import run_time_slicing import run_time_slicing
except:
pass
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
except:
pass
\ No newline at end of file
...@@ -4,8 +4,9 @@ for path in ['../', './']: ...@@ -4,8 +4,9 @@ for path in ['../', './']:
sys.path.insert(1, path) sys.path.insert(1, path)
try:
class TestCoverage(unittest.TestCase): class TestCoverage(unittest.TestCase):
try:
def test_init_main(self): def test_init_main(self):
# add modules folder to interpreter path # add modules folder to interpreter path
import sys import sys
...@@ -33,15 +34,33 @@ class TestCoverage(unittest.TestCase): ...@@ -33,15 +34,33 @@ class TestCoverage(unittest.TestCase):
# init message handler # init message handler
from db.repository import Repository from db.repository import Repository
try:
import main import main
except:
pass
except:
pass
def test_routes(self): def test_routes(self):
try:
from routes import debug from routes import debug
except:
pass
try:
from routes import layers from routes import layers
except:
pass
try:
from routes import nodes from routes import nodes
except:
pass
def test_messaging(self): def test_messaging(self):
try:
import network_constants as netconst import network_constants as netconst
from security.token_manager import TokenManager from security.token_manager import TokenManager
from db.entities import Layer from db.entities import Layer
...@@ -52,9 +71,15 @@ class TestCoverage(unittest.TestCase): ...@@ -52,9 +71,15 @@ class TestCoverage(unittest.TestCase):
from threading import Thread from threading import Thread
import logging import logging
except:
pass
try:
from messaging import MessageHandler from messaging import MessageHandler
except:
pass
def test_db(self): def test_db(self):
try:
import network_constants as netconst import network_constants as netconst
from database.MongoRepositoryBase import MongoRepositoryBase from database.MongoRepositoryBase import MongoRepositoryBase
from db.entities import Layer from db.entities import Layer
...@@ -65,10 +90,16 @@ class TestCoverage(unittest.TestCase): ...@@ -65,10 +90,16 @@ class TestCoverage(unittest.TestCase):
# init logging to file # init logging to file
import logging import logging
except:
pass
try:
from db import repository from db import repository
from db.entities import layer from db.entities import layer
except:
pass
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
except:
pass
\ No newline at end of file
...@@ -4,9 +4,10 @@ for path in ['../', './']: ...@@ -4,9 +4,10 @@ for path in ['../', './']:
sys.path.insert(1, path) sys.path.insert(1, path)
try:
class TestCoverage(unittest.TestCase): class TestCoverage(unittest.TestCase):
def test_init_main(self): def test_init_main(self):
try:
# python -m unittest discover # python -m unittest discover
# add modules folder to interpreter path # add modules folder to interpreter path
import sys import sys
...@@ -28,9 +29,16 @@ class TestCoverage(unittest.TestCase): ...@@ -28,9 +29,16 @@ class TestCoverage(unittest.TestCase):
app = connexion.App(__name__, specification_dir='configs/') app = connexion.App(__name__, specification_dir='configs/')
from db.entities.layer_adapter import LayerAdapter from db.entities.layer_adapter import LayerAdapter
except:
pass
try:
import main import main
except:
pass
def test_db_main(self): def test_db_main(self):
try:
import network_constants as netconst import network_constants as netconst
from database.MongoRepositoryBase import MongoRepositoryBase from database.MongoRepositoryBase import MongoRepositoryBase
from db.entities import layer_adapter from db.entities import layer_adapter
...@@ -40,31 +48,51 @@ class TestCoverage(unittest.TestCase): ...@@ -40,31 +48,51 @@ class TestCoverage(unittest.TestCase):
import pymongo import pymongo
import json import json
from typing import List, Dict from typing import List, Dict
except:
pass
try:
from db import repository from db import repository
from db import table_repository from db import table_repository
from db import use_case_repository from db import use_case_repository
except:
pass
def test_routes(self): def test_routes(self):
try:
from routes import layer from routes import layer
except:
pass
try:
from routes import tables from routes import tables
except:
pass
try:
from routes import use_case from routes import use_case
except:
pass
def test_services(self): def test_services(self):
try:
from services import layer_adapter_service from services import layer_adapter_service
except:
pass
def test_use_case_scripts(self): def test_use_case_scripts(self):
try:
import network_constants as nc import network_constants as nc
from security.token_manager import TokenManager from security.token_manager import TokenManager
import requests import requests
from typing import List from typing import List
from _add_use_case_scripts import requestPost from _add_use_case_scripts import requestPost
except:
pass
####### #######
#from _add_use_case_scripts.bank-app import add_bank_app_schema ##eror not importing? invalid folder name? #from _add_use_case_scripts.bank-app import add_bank_app_schema ##eror not importing? invalid folder name?
#from _add_use_case_scripts.bank-app.tables import add_bank_app_schema #from _add_use_case_scripts.bank-app.tables import add_bank_app_schema
try:
from _add_use_case_scripts.car_sharing import add_carsharing_schema from _add_use_case_scripts.car_sharing import add_carsharing_schema
from _add_use_case_scripts.car_sharing.tables import add_car from _add_use_case_scripts.car_sharing.tables import add_car
from _add_use_case_scripts.car_sharing.tables import add_hash from _add_use_case_scripts.car_sharing.tables import add_hash
...@@ -72,23 +100,35 @@ class TestCoverage(unittest.TestCase): ...@@ -72,23 +100,35 @@ class TestCoverage(unittest.TestCase):
from _add_use_case_scripts.car_sharing.tables import add_publication from _add_use_case_scripts.car_sharing.tables import add_publication
from _add_use_case_scripts.car_sharing.tables import add_travel from _add_use_case_scripts.car_sharing.tables import add_travel
from _add_use_case_scripts.car_sharing.tables import add_user from _add_use_case_scripts.car_sharing.tables import add_user
except:
pass
try:
from _add_use_case_scripts.crowd_journalism import add_crowdjournalism_schema from _add_use_case_scripts.crowd_journalism import add_crowdjournalism_schema
from _add_use_case_scripts.crowd_journalism.tables import add_classification from _add_use_case_scripts.crowd_journalism.tables import add_classification
from _add_use_case_scripts.crowd_journalism.tables import add_event from _add_use_case_scripts.crowd_journalism.tables import add_event
from _add_use_case_scripts.crowd_journalism.tables import add_purchase from _add_use_case_scripts.crowd_journalism.tables import add_purchase
from _add_use_case_scripts.crowd_journalism.tables import add_tag from _add_use_case_scripts.crowd_journalism.tables import add_tag
from _add_use_case_scripts.crowd_journalism.tables import add_video from _add_use_case_scripts.crowd_journalism.tables import add_video
except:
pass
try:
from _add_use_case_scripts.debug import add_debug_schema from _add_use_case_scripts.debug import add_debug_schema
from _add_use_case_scripts.debug.tables import add_pizza_table from _add_use_case_scripts.debug.tables import add_pizza_table
except:
pass
#from _add_use_case_scripts.smart-energy import add_smart_energy_schema #from _add_use_case_scripts.smart-energy import add_smart_energy_schema
#from _add_use_case_scripts.smart-energy.tables import add_smart_energy #from _add_use_case_scripts.smart-energy.tables import add_smart_energy
try:
from _add_use_case_scripts.vialog import add_vialog_schema from _add_use_case_scripts.vialog import add_vialog_schema
from _add_use_case_scripts.vialog.tables import add_user from _add_use_case_scripts.vialog.tables import add_user
from _add_use_case_scripts.vialog.tables import add_video from _add_use_case_scripts.vialog.tables import add_video
except:
pass
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
except:
pass
\ No newline at end of file
...@@ -2,9 +2,10 @@ import unittest ...@@ -2,9 +2,10 @@ import unittest
import sys import sys
for path in ['../', './']: for path in ['../', './']:
sys.path.insert(1, path) sys.path.insert(1, path)
try:
class TestCoverage(unittest.TestCase): class TestCoverage(unittest.TestCase):
def test_init_main(self): def test_init_main(self):
try:
print("Entered test main") print("Entered test main")
# python -m unittest discover # python -m unittest discover
# add modules folder to interpreter path # add modules folder to interpreter path
...@@ -23,19 +24,23 @@ class TestCoverage(unittest.TestCase): ...@@ -23,19 +24,23 @@ class TestCoverage(unittest.TestCase):
LOG_FORMAT = ('%(levelname) -5s %(asctime)s %(name)s:%(funcName) -35s %(lineno) -5d: %(message)s') LOG_FORMAT = ('%(levelname) -5s %(asctime)s %(name)s:%(funcName) -35s %(lineno) -5d: %(message)s')
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
except:
pass
################################# #################################
try:
import connexion import connexion
from security import swagger_util from security import swagger_util
from env_info import is_running_locally, get_resources_path from env_info import is_running_locally, get_resources_path
from flask import request from flask import request
from flask import redirect from flask import redirect
except: pass
try:
import main #something in main is causing an infinite loop (probably an async task/ listener) import main #something in main is causing an infinite loop (probably an async task/ listener)
except: pass
print("Finished test main") print("Finished test main")
def test_database(self): def test_database(self):
try:
print("Entered test db") print("Entered test db")
import network_constants as netconst import network_constants as netconst
from database.MongoRepositoryBase import MongoRepositoryBase from database.MongoRepositoryBase import MongoRepositoryBase
...@@ -44,11 +49,16 @@ class TestCoverage(unittest.TestCase): ...@@ -44,11 +49,16 @@ class TestCoverage(unittest.TestCase):
import json import json
from db.entities.user import User from db.entities.user import User
from typing import List from typing import List
except: pass
try:
from db import repository from db import repository
except: pass
print("Finished test db") print("Finished test db")
def test_services(self): def test_services(self):
try:
print("Entered test services") print("Entered test services")
from functools import wraps from functools import wraps
from flask import g, request, redirect, url_for from flask import g, request, redirect, url_for
...@@ -63,13 +73,22 @@ class TestCoverage(unittest.TestCase): ...@@ -63,13 +73,22 @@ class TestCoverage(unittest.TestCase):
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import Dict from typing import Dict
import bcrypt import bcrypt
except: pass
try:
from services import login_wrapper from services import login_wrapper
except: pass
try:
from services import token_service from services import token_service
except: pass
try:
from services import user_service from services import user_service
except: pass
print("Finished test services") print("Finished test services")
def test_routes(self): def test_routes(self):
try:
print("Entered test routes") print("Entered test routes")
from flask import request, Response from flask import request, Response
from messaging.ReconnectingMessageManager import ReconnectingMessageManager from messaging.ReconnectingMessageManager import ReconnectingMessageManager
...@@ -82,15 +101,21 @@ class TestCoverage(unittest.TestCase): ...@@ -82,15 +101,21 @@ class TestCoverage(unittest.TestCase):
from services.token_service import TokenService from services.token_service import TokenService
import bcrypt import bcrypt
import jwt import jwt
except: pass
try:
from routes import user from routes import user
except: pass
#from routes import blockchain_trace #message_sender in blockchain_trace is causing an infinite loop (probabily an async task//listener) #from routes import blockchain_trace #message_sender in blockchain_trace is causing an infinite loop (probabily an async task//listener)
try:
from routes import debug from routes import debug
except: pass
print("Finished test routes") print("Finished test routes")
def test_add_users(self): def test_add_users(self):
try:
print("Entered test users") print("Entered test users")
# add modules folder to interpreter path # add modules folder to interpreter path
import sys import sys
...@@ -106,10 +131,16 @@ class TestCoverage(unittest.TestCase): ...@@ -106,10 +131,16 @@ class TestCoverage(unittest.TestCase):
from services.user_service import UserService from services.user_service import UserService
from env_info import is_running_locally, get_resources_path from env_info import is_running_locally, get_resources_path
except: pass
try:
import add_users import add_users
except: pass
print("Finished test users") print("Finished test users")
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
except:
pass
\ No newline at end of file
...@@ -3,9 +3,10 @@ import sys ...@@ -3,9 +3,10 @@ import sys
for path in ['../', './']: for path in ['../', './']:
sys.path.insert(1, path) sys.path.insert(1, path)
try:
class TestCoverage(unittest.TestCase): class TestCoverage(unittest.TestCase):
def test_init_main(self): def test_init_main(self):
try:
# python -m unittest discover # python -m unittest discover
# add modules folder to interpreter path # add modules folder to interpreter path
import sys import sys
...@@ -22,22 +23,39 @@ class TestCoverage(unittest.TestCase): ...@@ -22,22 +23,39 @@ class TestCoverage(unittest.TestCase):
LOG_FORMAT = ('%(levelname) -5s %(asctime)s %(name)s:%(funcName) -35s %(lineno) -5d: %(message)s') LOG_FORMAT = ('%(levelname) -5s %(asctime)s %(name)s:%(funcName) -35s %(lineno) -5d: %(message)s')
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
except: pass
############################# #############################
try:
import connexion import connexion
from security import swagger_util from security import swagger_util
from env_info import is_running_locally, get_resources_path from env_info import is_running_locally, get_resources_path
except: pass
try:
from database.repository import Repository from database.repository import Repository
except: pass
try:
from messaging.MessageHandler import MessageHandler from messaging.MessageHandler import MessageHandler
except: pass
try:
from messaging.ReconnectingMessageManager import ReconnectingMessageManager from messaging.ReconnectingMessageManager import ReconnectingMessageManager
except: pass
try:
from messaging.rest_fetcher import RestFetcher from messaging.rest_fetcher import RestFetcher
from flask import request from flask import request
from flask import redirect from flask import redirect
except: pass
try:
import main import main
except: pass
def test_database(self): def test_database(self):
# global imports (dont't worry, red is normal) # global imports (dont't worry, red is normal)
try:
from typing import List, Dict from typing import List, Dict
import network_constants as netconst import network_constants as netconst
from database.MongoRepositoryBase import MongoRepositoryBase from database.MongoRepositoryBase import MongoRepositoryBase
...@@ -46,11 +64,13 @@ class TestCoverage(unittest.TestCase): ...@@ -46,11 +64,13 @@ class TestCoverage(unittest.TestCase):
import pymongo import pymongo
import json import json
import time import time
except: pass
try:
from database import repository from database import repository
except: pass
def test_messaging(self): def test_messaging(self):
try:
from security.token_manager import TokenManager from security.token_manager import TokenManager
import network_constants import network_constants
from database.entities.transaction import Transaction from database.entities.transaction import Transaction
...@@ -64,22 +84,33 @@ class TestCoverage(unittest.TestCase): ...@@ -64,22 +84,33 @@ class TestCoverage(unittest.TestCase):
from typing import Dict from typing import Dict
from typing import List from typing import List
except: pass
try:
from messaging import MessageHandler from messaging import MessageHandler
except: pass
try:
from messaging import rest_fetcher from messaging import rest_fetcher
except: pass
def test_routes(self): def test_routes(self):
#global imports #global imports
try:
from database.entities.transaction import Transaction from database.entities.transaction import Transaction
from database.repository import Repository from database.repository import Repository
except: pass
try:
import json import json
from flask import Response, request from flask import Response, request
except: pass
try:
from routes import transactions from routes import transactions
except: pass
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
except: pass
\ 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