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'
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'
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'
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)
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'] )
def test_get_components(): from python_moonutilities import configuration assert isinstance(configuration.get_components(), dict)