import unittest
import sys
for path in ['../', './']:
    sys.path.insert(1, path)

#####################################
### Don't include for test report ###
#####################################
try:
    class TestCoverage(unittest.TestCase):
        def test_init_main(self):
            try:
                # add modules folder to interpreter path
                import sys
                import os
                import prance
                from pathlib import Path
                modules_path = '../../../modules/'
                if os.path.exists(modules_path):
                    sys.path.insert(1, modules_path)

                # init logging to file
                import logging
                LOG_FORMAT = ('%(levelname) -5s %(asctime)s %(name)s:%(funcName) -35s %(lineno) -5d:  %(message)s')
                logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
                LOGGER = logging.getLogger(__name__)

                #################################
                import connexion
                from security import swagger_util
                from env_info import is_running_locally, get_resources_path
                from messaging.ReconnectingMessageManager import ReconnectingMessageManager
                from messaging.MessageHandler import MessageHandler
                from flask import request
                from flask import redirect

                # init message handler
                from db.repository import Repository
            except Exception as e:
                print ("Exception found:")
                print (e)
            try:

                import main

            except Exception as e:
                print ("Exception found:")
                print (e)

        def test_routes(self):
            try:
                from routes import debug
            except Exception as e:
                print ("Exception found:")
                print (e)

            try:
                from routes import layers
            except Exception as e:
                print ("Exception found:")
                print (e)

            try:
                from routes import nodes
            except Exception as e:
                print ("Exception found:")
                print (e)

        def test_messaging(self):
            try:
                import network_constants as netconst
                from security.token_manager import TokenManager
                from db.entities import Layer

                import json
                import requests
                from typing import Dict, List
                from threading import Thread

                import logging
            except Exception as e:
                print ("Exception found:")
                print (e)
            try:
                from messaging import MessageHandler
            except Exception as e:
                print ("Exception found:")
                print (e)

        def test_db(self):
            try:
                import network_constants as netconst
                from database.MongoRepositoryBase import MongoRepositoryBase
                from db.entities import Layer

                import pymongo
                import json
                from typing import List, Dict

                # init logging to file
                import logging
            except Exception as e:
                print ("Exception found:")
                print (e)
            try:
                from db import repository
                from db.entities import layer
            except Exception as e:
                print ("Exception found:")
                print (e)


    if __name__ == '__main__':
        unittest.main()
except Exception as e:
                print ("Exception found:")
                print (e)