Exemplo n.º 1
0
def test_get_components_not_found(**kwargs):
    from python_moonutilities import configuration

    kwargs['mock'].get('http://consul:8500/v1/kv/components?recurse=true', json=[
    ], status_code=500)
    with pytest.raises(Exception) as exception_info:
        configuration.get_components()
    assert str(exception_info.value) == '400: Consul error'
Exemplo n.º 2
0
def test_get_components_invalid_response(**kwargs):
    from python_moonutilities import configuration

    kwargs['mock'].get('http://consul:8500/v1/kv/components?recurse=true', json=[
        {"invalidKey":'invalid', 'Value': "jb250"}
    ])
    with pytest.raises(Exception) as exception_info:
        configuration.get_components()
    assert str(exception_info.value) == '500: Consul Content error'
Exemplo n.º 3
0
def test_get_components_mutliple_list_failure(**kwargs):
    from python_moonutilities import configuration

    kwargs['mock'].get('http://consul:8500/v1/kv/components?recurse=true',
                       json=[
                           {'Key': 'components/c1', 'Value': "eyJjb250YWluZXIiOiAid3Vrb25"},
                           {'invalidKey': 'components/c2', 'Value': "eyJjb250YWluZXIiOiAid3Vrb25"}
                             ]
                       )
    with pytest.raises(Exception) as exception_info:
        configuration.get_components()
    assert str(exception_info.value) == '500: Consul Content error'
Exemplo n.º 4
0
def test_get_components_mutliple_list_success(**kwargs):
    from python_moonutilities import configuration

    kwargs['mock'].get('http://consul:8500/v1/kv/components?recurse=true',
                       json=[
                           {'Key': 'components/c1', 'Value': 'eyJjb250YWluZXIiOiAid3Vrb25nc3VuL21vb25fYXV0aHo6djQuMyIsICJwb3J0IjogODA4MX0='},
                           {'Key': 'components/c2', 'Value': 'eyJjb250YWluZXIiOiAid3Vrb25nc3VuL21vb25fYXV0aHo6djQuMyIsICJwb3J0IjogODA4MX0='}
                             ]
                       )

    res = configuration.get_components()
    assert bool(res)
Exemplo n.º 5
0
 def __init__(self):
     self.manager_url = "{}://{}:{}".format(
         configuration.get_components()['manager'].get('protocol', 'http'),
         configuration.get_components()['manager']['hostname'],
         configuration.get_components()['manager']['port']
     )
     self.orchestrator_url = "{}://{}:{}".format(
         configuration.get_components()['orchestrator'].get('protocol', 'http'),
         configuration.get_components()['orchestrator']['hostname'],
         configuration.get_components()['orchestrator']['port']
     )
Exemplo n.º 6
0
def test_get_components():
    from python_moonutilities import configuration
    assert isinstance(configuration.get_components(), dict)