Esempio n. 1
0
def startMyApplicationTest():
    # Act
    globals.newGlobalsInstance(__file__,
                               loadLocalConfig=False,
                               logStatus=False,
                               infoStatus=False,
                               debugStatus=True,
                               warningStatus=True,
                               errorStatus=True,
                               successStatus=True,
                               failureStatus=True,
                               settingStatus=True,
                               encoding='utf-8',
                               printRootPathStatus=False,
                               globalsEverything=False)
Esempio n. 2
0
def myConfigurationTests_whenEnvironmentVariableIsPresent():
    # Arrange
    globalsInstance = globals.newGlobalsInstance(__file__,
                                                 loadLocalConfig=False)
    expected = 'my configuration value injected through environmnet variable'

    # Act
    toAssert = globalsInstance.getSetting('my.configuration')

    # Assert
    assert expected == toAssert
Esempio n. 3
0
 def tddModule(testName, testModule, dataList, times, runSpecificTests,
               testsToRun, allShouldRun, someShouldRun, logResult):
     import globals
     tddModuleGlobalsInstance = globals.newGlobalsInstance(
         testModule.__file__,
         successStatus=globalsInstance.successStatus,
         errorStatus=globalsInstance.errorStatus,
         settingStatus=globalsInstance.settingStatus or inspectGlobals,
         debugStatus=globalsInstance.debugStatus,
         warningStatus=globalsInstance.warningStatus,
         wrapperStatus=globalsInstance.wrapperStatus,
         testStatus=globalsInstance.testStatus,
         logStatus=globalsInstance.logStatus)
     LogHelper.test(tddModule, f'{testName} started')
     testReturns = {}
     testTime = 0
     for data in dataList:
         testMustRun = isTestToRun(testModule, data, runSpecificTests,
                                   testsToRun)
         LogHelper.prettyPython(tddModule,
                                f'test attribute or method',
                                data[0],
                                logLevel=LogHelper.TEST)
         LogHelper.prettyPython(tddModule,
                                f'isTestToRun',
                                testMustRun,
                                logLevel=LogHelper.TEST)
         if testMustRun:
             for index in range(times):
                 testTimeStart = time.time()
                 if times - 1 == index:
                     runnableUnitTest = getUnitTest(inspectGlobals,
                                                    globalsInstance)
                     testName, data, testReturns, someDidRun, logResult, discountTimeEnd = runnableUnitTest(
                         testModule, testName, data, testReturns, logResult)
                 else:
                     runnableUnitTestBatch = getUnitTestBatch(
                         inspectGlobals, globalsInstance)
                     discountTimeEnd = runnableUnitTestBatch(
                         testModule, data)
                 testTime += time.time() - discountTimeEnd
         else:
             allDidRun = False
     if not allShouldRun == allDidRun and someShouldRun == someDidRun:
         amountAlthought = getAmmount(allShouldRun, someShouldRun)
         shouldOrShouldnt = getShouldOrShouldntAsString(
             allShouldRun, someShouldRun)
         amountAfterAlthought = getAmmount(allDidRun, someDidRun)
         didOrDidnt = getSomeDidOrDidntAsString(allDidRun, someDidRun)
         errorMessage = f'Inconsistenc{StringHelper.getS(allShouldRun or someShouldRun, es=True)} detected. Although {amountAlthought} test{StringHelper.getS(allShouldRun or someShouldRun)} {shouldOrShouldnt} run, {amountAfterAlthought} {didOrDidnt} run'
         exception = Exception(errorMessage)
         raise exception
     return allDidRun, someDidRun, testTime, testReturns
Esempio n. 4
0
def myConfigurationTests_whenEnvironmentVariableIsNotPresentAndIsSettingKeyReferencedAndSettingKeyAlreadyIsDefined(
):
    # Arrange
    globalsInstance = globals.newGlobalsInstance(__file__,
                                                 loadLocalConfig=False)
    expected = globalsInstance.getSetting('my.self-reference-key')

    # Act
    toAssert = globalsInstance.getSetting('my.configuration')

    # Assert
    assert expected == toAssert
Esempio n. 5
0
def run(filePath,
        runOnly=None,
        ignore=None,
        times=1,
        successStatus=True,
        errorStatus=True,
        settingStatus=False,
        debugStatus=True,
        warningStatus=True,
        failureStatus=True,
        wrapperStatus=False,
        testStatus=False,
        logStatus=False,
        inspectGlobals=False,
        logResult=True):
    import globals
    globalsInstance = globals.newGlobalsInstance(filePath,
                                                 successStatus=successStatus,
                                                 errorStatus=errorStatus,
                                                 settingStatus=settingStatus
                                                 or inspectGlobals,
                                                 debugStatus=debugStatus,
                                                 warningStatus=warningStatus,
                                                 failureStatus=failureStatus,
                                                 wrapperStatus=wrapperStatus,
                                                 testStatus=testStatus,
                                                 logStatus=logStatus)
    testModuleNames, testsToRun, runSpecificTests = getTestModuleNames(
        runOnly, ignore, globalsInstance)
    returns = {}
    totalTestTimeStart = time.time()
    testTime = 0
    for testModuleName in testModuleNames:
        runnableTddModule = getModuleTest(inspectGlobals, logResult,
                                          globalsInstance)
        allDidRun, didRun, moduleTestTime, testReturns = runModuleTests(
            testModuleName, runnableTddModule, times, runSpecificTests,
            testsToRun, logResult, globalsInstance)
        returns[testModuleName] = testReturns
        testTime += moduleTestTime
    totalTestTime = time.time() - totalTestTimeStart
    if logResult:
        LogHelper.success(
            run,
            f'{globalsInstance.apiName} tests completed. {getTestRuntimeInfo(times, testTime, totalTestTime)}'
        )
    return returns
Esempio n. 6
0
def shouldHandleMissingEnvironmentSettings():
    # Arrange
    exception = None
    globalsInstance = None

    # Act
    try:
        globalsInstance = globals.newGlobalsInstance(__file__,
                                                     loadLocalConfig=False)
    except Exception as ext:
        exception = ext

    # Assert
    assert ObjectHelper.isNotNone(globalsInstance)
    assert ObjectHelper.isNone(exception)
    assert 'missing_setting_file' == EnvironmentHelper.get(
        SettingHelper.ACTIVE_ENVIRONMENT)
    assert 'missing_setting_file' == SettingHelper.getActiveEnvironment()
Esempio n. 7
0
def newApp(filePath,
           successStatus=True,
           errorStatus=True,
           failureStatus=True,
           warningStatus=True,
           settingStatus=True,
           statusStatus=True,
           infoStatus=True,
           debugStatus=False,
           wrapperStatus=False,
           testStatus=False,
           logStatus=False):
    globalsInstance = globals.newGlobalsInstance(filePath,
                                                 successStatus=successStatus,
                                                 errorStatus=errorStatus,
                                                 failureStatus=failureStatus,
                                                 settingStatus=settingStatus,
                                                 statusStatus=statusStatus,
                                                 infoStatus=infoStatus,
                                                 debugStatus=debugStatus,
                                                 warningStatus=warningStatus,
                                                 wrapperStatus=wrapperStatus,
                                                 testStatus=testStatus,
                                                 logStatus=logStatus)
    try:
        app = globals.importResource(
            KW_APP,
            resourceModuleName=ConverterStatic.getValueOrDefault(
                globalsInstance.apiName,
                StringHelper.join(EnvironmentHelper.listDirectoryContent(
                    f'{globalsInstance.BASE_API_PATH}')[0].split(c.DOT)[:-1],
                                  character=c.DOT)),
            required=True)
    except Exception as exception:
        apiPath = f'{c.DOT}{EnvironmentHelper.OS_SEPARATOR}{globalsInstance.BASE_API_PATH}{globalsInstance.apiName}.py'
        errorMessage = f"Not possible to load app. Make shure it's name is properlly configured at '{globalsInstance.settingFilePath}' and it's instance is named 'app' at '{apiPath}'"
        log.error(newApp, errorMessage, exception)
        raise exception
    if ObjectHelper.isNone(app):
        app = globals.importResource(
            KW_APP, resourceModuleName=globalsInstance.apiName)
        raise Exception(
            'Not possible to load app. Check logs for more details')
    return app
def runGlobals(filePath,
               successStatus=False,
               settingStatus=False,
               debugStatus=False,
               warningStatus=False,
               wrapperStatus=False,
               failureStatus=False,
               errorStatus=False,
               testStatus=False,
               logStatus=False):
    return globals.newGlobalsInstance(filePath,
                                      successStatus=successStatus,
                                      settingStatus=settingStatus,
                                      debugStatus=debugStatus,
                                      warningStatus=warningStatus,
                                      wrapperStatus=wrapperStatus,
                                      failureStatus=failureStatus,
                                      errorStatus=errorStatus,
                                      testStatus=testStatus,
                                      logStatus=logStatus)
Esempio n. 9
0
def myConfigurationTests_musHandleSettingsWithNoSelfOrCircularReference():
    # Arrange
    globalsInstance = globals.newGlobalsInstance(__file__,
                                                 loadLocalConfig=False,
                                                 debugStatus=False,
                                                 warningStatus=False,
                                                 errorStatus=False,
                                                 successStatus=False,
                                                 failureStatus=False,
                                                 settingStatus=False,
                                                 logStatus=False,
                                                 encoding='utf-8',
                                                 printRootPathStatus=False,
                                                 globalsEverything=False)
    expected = 'Globals - no self reference'

    # Act
    toAssert = globalsInstance.getSetting('api.name')

    # Assert
    assert expected == toAssert
Esempio n. 10
0
import globals
globalsInstance = globals.newGlobalsInstance(
    __file__,
    loadLocalConfig=False,
    settingStatus=True,
    successStatus=True,
    errorStatus=True,
    debugStatus=True,
    warningStatus=True
    # wrapperStatus = True,
    # failureStatus = True,
    # logStatus = True,
    # testStatus = True,
)


def pythonFrameworkDefaultRunMethod(commandList, globals, **kwargs):
    globalsInstance.debug(
        f'"pythonFrameworkDefaultRunMethod()" method not implemented')


if __name__ == '__main__':
    globalsInstance.giveLocalVisibilityToFrameworkApis([
        'globals', 'python_helper', 'python_selenium_helper',
        'swagger_integration_tests'
    ])
    import PythonFramework
    PythonFramework.run(pythonFrameworkDefaultRunMethod, globalsInstance)
Esempio n. 11
0
import globals
globalsInstance = globals.newGlobalsInstance(__file__
    , settingStatus=True
    , successStatus = True
    , errorStatus = True
    , failureStatus = True
    # , debugStatus = True
    #
    # , warningStatus = True
    # , wrapperStatus = True
    # , logStatus = True
    # , testStatus = True
)

from python_framework import initialize, runApi
import IdealizarWhatsAppManagerApi
app = IdealizarWhatsAppManagerApi.app
api = IdealizarWhatsAppManagerApi.api
jwt = IdealizarWhatsAppManagerApi.jwt

@initialize(api, defaultUrl = '/swagger', openInBrowser=False)
def runFlaskApplication(app):
    runApi(debug=False, use_reloader=False)
    # app.run(debug=True)

if __name__ == '__main__' :
    runFlaskApplication(app)
Esempio n. 12
0
from python_helper import EnvironmentHelper, log

from python_helper import SettingHelper

import globals
globalsInstance = globals.newGlobalsInstance(__file__
    , loadLocalConfig = SettingHelper.activeEnvironmentIsDefault()

    , settingStatus = True
    , successStatus = True
    , errorStatus = True

    , debugStatus = True
    , failureStatus = True
    , warningStatus = True
    , wrapperStatus = True
    , logStatus = True
    # , testStatus = True
)

from python_framework.api.src.service.flask import FlaskManager
import TestApi
app = TestApi.app
api = TestApi.api
jwt = TestApi.jwt

@FlaskManager.initialize(api, defaultUrl = '/swagger', openInBrowser=False)
def runFlaskApplication(app=None):
    FlaskManager.runApi(debug=False, use_reloader=False)
    # app.run(debug=False, use_reloader=False)
    # app.run(debug=True)
Esempio n. 13
0
def getBooleanSetting():
    #arrange
    globalsInstance = globals.newGlobalsInstance(
        __file__, debugStatus=True, settingsFileName='boolean-application')

    #act
    falseValue = globalsInstance.getApiSetting('boolean.value.false')
    trueValue = globalsInstance.getApiSetting('boolean.value.true')
    environmentInjectionTrueValue = globalsInstance.getApiSetting(
        'boolean.value.environment-injection.true')
    environmentInjectionFalseValue = globalsInstance.getApiSetting(
        'boolean.value.environment-injection.false')
    isTrue = globalsInstance.getApiSetting(
        'boolean.value.environment-injection.is-true')
    isFalse = globalsInstance.getApiSetting(
        'boolean.value.environment-injection.is-false')
    shouldBeFalse = globalsInstance.getApiSetting(
        'boolean.value.environment-injection.this-is-false')
    shouldBeTrue = globalsInstance.getApiSetting(
        'boolean.value.environment-injection.this-is-true')
    thisIsAlsoTrue = globalsInstance.getApiSetting(
        'boolean.value.environment-injection.this-is-also-true')
    thisIsAlsoFalse = globalsInstance.getApiSetting(
        'boolean.value.environment-injection.this-is-also-false')

    #assert
    assert trueValue, f'trueValue should be True with type bool, but is {trueValue} with type {type(trueValue)}'
    assert bool == type(
        trueValue
    ), f'trueValue should be True with type bool, but is {trueValue} with type {type(trueValue)}'
    assert not falseValue, f'falseValue should be False with type bool, but is {falseValue} with type {type(falseValue)}'
    assert bool == type(
        falseValue
    ), f'falseValue should be False with type bool, but is {falseValue} with type {type(falseValue)}'

    assert environmentInjectionTrueValue, f'environmentInjectionTrueValue should be True with type bool, but is {environmentInjectionTrueValue} with type {type(environmentInjectionTrueValue)}'
    assert bool == type(
        environmentInjectionTrueValue
    ), f'environmentInjectionTrueValue should be True with type bool, but is {environmentInjectionTrueValue} with type {type(environmentInjectionTrueValue)}'
    assert not environmentInjectionFalseValue, f'environmentInjectionFalseValue should be False with type bool, but is {environmentInjectionFalseValue} with type {type(environmentInjectionFalseValue)}'
    assert bool == type(
        environmentInjectionFalseValue
    ), f'environmentInjectionFalseValue should be False with type bool, but is {environmentInjectionFalseValue} with type {type(environmentInjectionFalseValue)}'

    assert isTrue, f'isTrue with type bool, but is {isTrue} with type {type(isTrue)}'
    assert bool == type(
        isTrue
    ), f'isTrue with type bool, but is {isTrue} with type {type(isTrue)}'
    assert not isFalse, f'isFalse with type bool, but is {isFalse} with type {type(isFalse)}'
    assert bool == type(
        isFalse
    ), f'isFalse with type bool, but is {isFalse} with type {type(isFalse)}'

    assert shouldBeTrue, f'shouldBeTrue with type bool, but is {shouldBeTrue} with type {type(shouldBeTrue)}'
    assert bool == type(
        shouldBeTrue
    ), f'shouldBeTrue with type bool, but is {shouldBeTrue} with type {type(shouldBeTrue)}'
    assert not shouldBeFalse, f'shouldBeFalse with type bool, but is {shouldBeFalse} with type {type(shouldBeFalse)}'
    assert bool == type(
        shouldBeFalse
    ), f'shouldBeFalse with type bool, but is {shouldBeFalse} with type {type(shouldBeFalse)}'

    assert thisIsAlsoTrue, f'thisIsAlsoTrue with type bool, but is {thisIsAlsoTrue} with type {type(thisIsAlsoTrue)}'
    assert bool == type(
        thisIsAlsoTrue
    ), f'thisIsAlsoTrue with type bool, but is {thisIsAlsoTrue} with type {type(thisIsAlsoTrue)}'
    assert not thisIsAlsoFalse, f'thisIsAlsoFalse with type bool, but is {thisIsAlsoFalse} with type {type(thisIsAlsoFalse)}'
    assert bool == type(
        thisIsAlsoFalse
    ), f'thisIsAlsoFalse with type bool, but is {thisIsAlsoFalse} with type {type(thisIsAlsoFalse)}'
Esempio n. 14
0
def mustLoadLocalConfiguration_correctly():
    # Arrange
    expected = {
        'print-status': False,
        'server': {
            'scheme': 'http',
            'host': 'localhost',
            'host-and-port': 'localhost:5050',
            'port': 5050,
            'servlet': {
                'context-path': '/test-api'
            }
        },
        'has-it': {
            'or-not': '?',
            'here': '?'
        },
        'flask-specific-port': 'flask run --host=0.0.0.0 --port=5001',
        'api': {
            'name': 'TestApi',
            'extension': 'yml',
            'dependency': {
                'update': False,
                'list': {
                    'web': [
                        'globals', 'python_helper', 'Popen', 'Path', 'numpy',
                        'pywin32', 'sqlalchemy'
                    ]
                }
            },
            'git': {
                'force-upgrade-command':
                'pip install --upgrade --force python_framework'
            },
            'static-package':
            'AppData\Local\Programs\Python\Python38-32\statics',
            'list': []
        },
        'swagger': {
            'info': {
                'title': 'TestApi',
                'version': '0.0.1',
                'description': 'description',
                'terms-of-service': 'http://swagger.io/terms/',
                'contact': {
                    'name': 'Samuel Jansen',
                    'email': '*****@*****.**'
                },
                'license': {
                    'name': 'Apache 2.0 / MIT License',
                    'url': 'http://www.apache.org/licenses/LICENSE-2.0.html'
                }
            },
            'host': 'localhost:5050',
            'schemes': ['http']
        },
        'python': {
            'version': 3.9
        }
    }

    # Act
    globalsInstance = globals.newGlobalsInstance(
        __file__, debugStatus=True, settingsFileName='fallback-priority')
    # log.prettyJson(mustLoadLocalConfiguration_correctly, 'Must Load Local Configuration setting tree', globalsInstance.settingTree, logLevel=log.DEBUG)

    # Assert
    assert ObjectHelper.equals(expected, globalsInstance.settingTree)
Esempio n. 15
0
def myConfigurationTests_basicVariableDefinitions():
    # Arrange and Act
    globalsInstance = globals.newGlobalsInstance(__file__,
                                                 loadLocalConfig=False,
                                                 debugStatus=True,
                                                 warningStatus=False,
                                                 errorStatus=True,
                                                 successStatus=True,
                                                 failureStatus=True,
                                                 settingStatus=True,
                                                 logStatus=False,
                                                 infoStatus=True,
                                                 encoding='utf-8',
                                                 printRootPathStatus=False,
                                                 globalsEverything=False)
    # log.prettyPython(myConfigurationTests_basicVariableDefinitions, 'settingTree', globalsInstance.settingTree, logLevel=log.DEBUG)

    # Assert
    assert 'self reference value' == globalsInstance.getSetting(
        'my.self-reference-key')
    assert 'other self reference value as well' == globalsInstance.getSetting(
        'my.other.self-reference-key.as-well')
    assert 'other repeated self reference value as well' == globalsInstance.getSetting(
        'my.other.repeated.self-reference-key.as-well')
    assert 'my default value' == globalsInstance.getSetting(
        'my.configuration-without-environment-variable-key')
    assert "my default value" == globalsInstance.getSetting(
        'my.configuration-without-environment-variable-key-with-value-surrounded-by-single-quotes'
    )
    assert 'my default value' == globalsInstance.getSetting(
        'my.configuration-without-environment-variable-key-and-space-after-colon'
    )
    assert 'self reference value' == globalsInstance.getSetting(
        'my.configuration')
    assert 'self reference value' == globalsInstance.getSetting(
        'my.own.configuration')
    assert 'other root value' == globalsInstance.getSetting('other.root.key')
    assert 'other root value' == globalsInstance.getSetting(
        'my.own.very.deep.configuration')
    assert 'other self reference value as well' == globalsInstance.getSetting(
        'my.other-with-other-name.self-reference-key.as-well')
    assert 'self reference value' == globalsInstance.getSetting(
        'my.other-with-other-name.configuration')
    assert 'other self reference value as well' == globalsInstance.getSetting(
        'my.other-with-other-name.configuration-as-well')
    assert 'other repeated self reference value as well' == globalsInstance.getSetting(
        'my.other-with-other-name.configuration-repeated-as-well')
    assert globalsInstance.getSetting('my.override-case.overridden') is None
    assert 'overrider configuration' == globalsInstance.getSetting(
        'my.override-case.overrider')

    assert 'delayed assignment value' == globalsInstance.getSetting(
        'some-reference.before-its-assignment')
    assert 'delayed assignment value' == globalsInstance.getSetting(
        'some-reference.much.before-its-assignment')
    assert "'''  value  ''' with spaces" == globalsInstance.getSetting(
        'some-key.with-an-enter-in-between-the-previous-one')
    assert f"""Hi
                every
            one""".replace('\t',
                           c.TAB) == globalsInstance.getSetting('long.string')
    assert f"""Hi
                            every
                            one
                            this
                            is
                            the
                            deepest
                            long
                                        string
                            here""".replace(
        '\t', c.TAB) == globalsInstance.getSetting(
            'deepest.long.string.ever.long.string')
    assert f"""me
                    being
        not
                    fshds""".replace(
        '\t', c.TAB) == globalsInstance.getSetting('not.idented.long.string')
    assert 'abcdefg' == globalsInstance.getSetting(
        'it.contains.one-setting-injection')
    assert 'abcdefghijklm' == globalsInstance.getSetting(
        'it.contains.two-consecutive-setting-injection')
    assert 'abcdefghijklm' == globalsInstance.getSetting(
        'it.contains.one-inside-of-the-other-setting-injection')
    assert 'ABCD-- my complex value --EFG' == globalsInstance.getSetting(
        'it.contains.one-setting-injection-with-environment-variable')
    assert 'ABCDEFGEFG-- my complex value --HIJKLMNOP' == globalsInstance.getSetting(
        'it.contains.one-inside-of-the-other-setting-injection-with-environment-variable'
    )
    assert 'abcdefghijklm' == globalsInstance.getSetting(
        'it.contains.two-consecutive-setting-injection-with-missing-environment-variable'
    )
    assert 'abcd-- late value ----abcd---- late value ----abcd--efg' == globalsInstance.getSetting(
        'it.contains.some-composed-key.pointing-to.a-late-value')
    assert 'abcd-- late environment value ----abcd--it.contains.late-value--abcd--efg' == globalsInstance.getSetting(
        'it.contains.some-composed-key.pointing-to.a-late-value-with-an-environment-variable-in-between'
    )
    assert '-- late value --' == globalsInstance.getSetting(
        'it.contains.late-value')
    assert 'only environment variable value' == globalsInstance.getSetting(
        'it.contains.environment-variable.only')
    assert 'ABCD -- only environment variable value -- EFGH' == globalsInstance.getSetting(
        'it.contains.environment-variable.surrounded-by-default-values')
    assert 'ABCD -- "some value followed by: "only environment variable value\' and some following default value\' -- EFGH' == globalsInstance.getSetting(
        'it.contains.environment-variable.in-between-default-values')
    assert 'ABCD -- very late definiton value -- EFGH' == globalsInstance.getSetting(
        'it.contains.refference.to-a-late-definition')
    assert 222233444 == globalsInstance.getSetting('handle.integer')
    assert 2.3 == globalsInstance.getSetting('handle.float')
    assert True == globalsInstance.getSetting('handle.boolean')
    assert 222233444 == globalsInstance.getSetting('handle.late.integer')
    assert 2.3 == globalsInstance.getSetting('handle.late.float')
    assert True == globalsInstance.getSetting('handle.late.boolean')
    assert [] == globalsInstance.getSetting('handle.empty.list')
    assert {} == globalsInstance.getSetting('handle.empty.dictionary-or-set')
    assert (()) == globalsInstance.getSetting('handle.empty.tuple')
    assert 'local' == globalsInstance.getSetting('environment.test')
    assert 'not at all' == globalsInstance.getSetting('environment.missing')
    assert 'ABCD -- 222233444 -- EFGH' == globalsInstance.getSetting(
        'some-not-string-selfreference.integer')
    assert 'ABCD -- 2.3 -- EFGH' == globalsInstance.getSetting(
        'some-not-string-selfreference.float')
    assert 'ABCD -- True -- EFGH' == globalsInstance.getSetting(
        'some-not-string-selfreference.boolean')
    assert ObjectHelper.equals(
        '/my/static/folder',
        globalsInstance.settingTree['python']['static-package'])
    assert ObjectHelper.equals(
        '/my/static/folder',
        globalsInstance.getSetting(globals.AttributeKey.PYTHON_STATIC_PACKAGE))
    assert ObjectHelper.equals('/my/static/folder',
                               globalsInstance.getStaticPackagePath())
Esempio n. 16
0
def mustLoadLocalConfiguration():
    # Arrange
    LOCAL_CONFIG_VALUE = 'local config setting value'
    FIRST_LONG_STRING = '''"""Hi
                every
            one
            """'''
    SECOND_LONG_STRING = '''"""Hi
                            every
                            one
                            this
                            is
                            the
                            deepest
                            long
                                        string
                            here
                            """'''
    THIRD_LONG_STRING = '''"""
                    me
                    being
        not
                    fshds
                    """'''
    expected = {
        'print-status': True,
        'local': {
            'config': {
                'setting-key': 'local config setting value'
            }
        },
        'database': {
            'dialect': 'a:b$c:d',
            'username': '******',
            'password': '******',
            'host': 'm:n*o:p',
            'port': '[q:r:s:t]',
            'schema': '(u:v:w:x)'
        },
        'environment': {
            'database': {
                'key': 'DATABASE_URL',
                'value':
                'a:b$c:d://e:f?g:h:i:j!k:l@m:n*o:p:[q:r:s:t]/(u:v:w:x)'
            },
            'test': 'production',
            'missing': 'not at all'
        },
        'server': {
            'scheme': 'https',
            'host': 'host',
            'servlet': {
                'context-path': '/test-api'
            },
            'port': 5050
        },
        'api': {
            'host-0': 'https://host',
            'host-1': 'https://host/test-api',
            'host-2': 'https://*****:*****@gmail.com'
                },
                'license': {
                    'name': 'Apache 2.0 / MIT License',
                    'url': 'http://www.apache.org/licenses/LICENSE-2.0.html'
                }
            },
            'schemes': ['https']
        },
        'python': {
            'version': 3.9
        },
        'some-reference': {
            'much': {
                'before-its-assignment': 'delayed assignment value'
            },
            'before-its-assignment': 'delayed assignment value'
        },
        'other': {
            'root': {
                'key': 'other root value'
            }
        },
        'my': {
            'self-reference-key':
            'self reference value',
            'other': {
                'self-reference-key': {
                    'as-well': 'other self reference value as well'
                },
                'repeated': {
                    'self-reference-key': {
                        'as-well':
                        'other repeated self reference value as well'
                    }
                }
            },
            'configuration-without-environment-variable-key':
            'my default value',
            'configuration-without-environment-variable-key-with-value-surrounded-by-single-quotes':
            'my default value',
            'configuration-without-environment-variable-key-and-space-after-colon':
            'my default value',
            'own': {
                'very': {
                    'deep': {
                        'configuration': 'other root value'
                    }
                },
                'configuration': 'self reference value'
            },
            'other-with-other-name': {
                'self-reference-key': {
                    'as-well': 'other self reference value as well'
                },
                'configuration':
                'self reference value',
                'configuration-as-well':
                'other self reference value as well',
                'configuration-repeated-as-well':
                'other repeated self reference value as well'
            },
            'override-case': {
                'overrider': 'overrider configuration'
            },
            'configuration':
            'self reference value'
        },
        'long': {
            'string': FIRST_LONG_STRING
        },
        'deepest': {
            'long': {
                'string': {
                    'ever': {
                        'long': {
                            'string': SECOND_LONG_STRING
                        }
                    }
                }
            }
        },
        'not': {
            'idented': {
                'long': {
                    'string': THIRD_LONG_STRING
                }
            }
        },
        'new-key': 'new value',
        'my-list': {
            'numbers': [1, 2, 3, 4],
            'simple-strings': ['a', 'b', 'c', 'd'],
            'complex': [2, 'b', 'c', 'd', 1, 2, True, True],
            'with-elemets-surrounded-by-all-sorts-of-quotes':
            ['a', 'b', 'c', 'd', 'e', 'f']
        },
        'specific-for': {
            'previous-assignment': 'delayed assignment value'
        },
        'some-key': {
            'with-an-enter-in-between-the-previous-one':
            "'''  value  ''' with spaces"
        },
        'it': {
            'contains': {
                'some-composed-key': {
                    'pointing-to': {
                        'a-late-value':
                        'abcd-- late value ----abcd---- late value ----abcd--efg',
                        'a-late-value-with-an-environment-variable-in-between':
                        'abcd-- late environment value ----abcd--it.contains.late-value--abcd--efg'
                    }
                },
                'late-value':
                '-- late value --',
                'environment-variable': {
                    'only':
                    'only environment variable value',
                    'surrounded-by-default-values':
                    'ABCD -- only environment variable value -- EFGH',
                    'in-between-default-values':
                    """ABCD -- "some value followed by: "only environment variable value' and some following default value' -- EFGH"""
                },
                'refference': {
                    'to-a-late-definition':
                    'ABCD -- very late definiton value -- EFGH'
                },
                'one-setting-injection':
                'abcdefg',
                'two-consecutive-setting-injection':
                'abcdefghijklm',
                'one-inside-of-the-other-setting-injection':
                'abcdefghijklm',
                'one-setting-injection-with-environment-variable':
                'ABCD-- my complex value --EFG',
                'one-inside-of-the-other-setting-injection-with-environment-variable':
                'ABCDEFGEFG-- my complex value --HIJKLMNOP',
                'two-consecutive-setting-injection-with-missing-environment-variable':
                'abcdefghijklm'
            }
        },
        'very-late': {
            'definition': 'very late definiton value'
        },
        'handle': {
            'late': {
                'integer': 222233444,
                'float': 2.3,
                'boolean': True
            },
            'integer': 222233444,
            'float': 2.3,
            'boolean': True,
            'empty': {
                'list': [],
                'dictionary-or-set': {},
                'tuple': ()
            }
        },
        'some': {
            'dictionary': {
                'yolo': 'yes',
                'another-yolo': 'no',
                'another-yolo-again': '',
                f'''{'{'}{" 'again?'"}''': f'''{"'yes' "}{'}'}'''
            }
        },
        'some-not-string-selfreference': {
            'integer': 'ABCD -- 222233444 -- EFGH',
            'float': 'ABCD -- 2.3 -- EFGH',
            'boolean': 'ABCD -- True -- EFGH'
        }
    }

    # Act
    globalsInstance = globals.newGlobalsInstance(
        __file__, settingStatus=True, settingsFileName='other-application')
    # globalsInstance.printTree(globalsInstance.settingTree, 'settingTree')
    # globalsInstance.printTree(globalsInstance.defaultSettingTree, 'defaultSettingTree')

    # Assert
    assert LOCAL_CONFIG_VALUE == globalsInstance.getSetting(
        'local.config.setting-key')
    assert True == globalsInstance.getSetting('print-status')
    assert 'Globals' == globalsInstance.getSetting('api.name')
    assert "a:b$c:d://e:f?g:h:i:j!k:l@m:n*o:p:[q:r:s:t]/(u:v:w:x)" == globalsInstance.getSetting(
        'environment.database.value')
    assert expected['long']['string'] == globalsInstance.settingTree['long'][
        'string']
    assert expected['deepest']['long']['string']['ever']['long'][
        'string'] == globalsInstance.settingTree['deepest']['long']['string'][
            'ever']['long']['string']
    assert expected['not']['idented']['long'][
        'string'] == globalsInstance.settingTree['not']['idented']['long'][
            'string']
    assert ObjectHelper.equals(
        expected['some']['dictionary'],
        globalsInstance.settingTree['some']['dictionary'])
    assert ObjectHelper.equals(expected,
                               globalsInstance.settingTree,
                               ignoreKeyList=[])