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:
                # python -m unittest discover
                # add modules folder to interpreter path
                import sys
                import os
                from pathlib import Path
                from typing import Dict, Any

                modules_path = '../../../modules/'
                if os.path.exists(modules_path):
                    sys.path.insert(1, modules_path)

                # load swagger config
                import connexion
                from security import swagger_util
                from env_info import is_running_locally, get_resources_path
                from flask import request
                from flask import redirect

                app = connexion.App(__name__, specification_dir='configs/')

                from db.entities.layer_adapter import LayerAdapter
            except Exception as e:
                print ("Exception found:")
                print (e)

            try:
                import main
            except Exception as e:
                print ("Exception found:")
                print (e)

        def test_db_main(self):
            try:
                import network_constants as netconst
                from database.MongoRepositoryBase import MongoRepositoryBase
                from db.entities import layer_adapter
                from db.entities import table
                from db.entities import use_case

                import pymongo
                import json
                from typing import List, Dict
            except Exception as e:
                print ("Exception found:")
                print (e)

            try:
                from db import repository
                from db import table_repository
                from db import use_case_repository
            except Exception as e:
                print ("Exception found:")
                print (e)
            

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

        def test_services(self):
            try:
                from services import layer_adapter_service
            except Exception as e:
                print ("Exception found:")
                print (e)

        def test_use_case_scripts(self):
            try:
                import network_constants as nc
                from security.token_manager import TokenManager
                import requests
                from typing import List
                from _add_use_case_scripts import requestPost
            except Exception as e:
                print ("Exception found:")
                print (e)
            #######

            #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
            try:
                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_hash
                from _add_use_case_scripts.car_sharing.tables import add_offer
                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_user
            except Exception as e:
                print ("Exception found:")
                print (e)

            try:
                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_event
                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_video
            except Exception as e:
                print ("Exception found:")
                print (e)
            
            try:
                from _add_use_case_scripts.debug import add_debug_schema
                from _add_use_case_scripts.debug.tables import add_pizza_table
            except Exception as e:
                print ("Exception found:")
                print (e)

            #from _add_use_case_scripts.smart-energy import add_smart_energy_schema
            #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.tables import add_user 
                from _add_use_case_scripts.vialog.tables import add_video
            except Exception as e:
                print ("Exception found:")
                print (e)
            
    if __name__ == '__main__':
        unittest.main()
except Exception as e:
    print ("Exception found:")
    print (e)