def get_recipes(): """ Return a list of recipes located in /adr/recipes path """ for file in os.listdir(recipe_path): if file.endswith('.py') and file != '__init__.py': recipe_name = file.rsplit('.', 1)[0] if not recipe.is_fail(recipe_name): recipe_lists.append(recipe_name) recipe_lists.sort()
def test_recipe(patch_active_data, recipe_test, validate, set_config): try: set_config(recipe=recipe_test['recipe'], fmt="json") patch_active_data(recipe_test) result = json.loads(run_recipe(recipe_test['recipe'], recipe_test['args'])) validate(recipe_test, result) except Exception as e: if is_fail(recipe_test['recipe']): xfail(str(e)) else: raise e
def test_api_error(patch_active_data_exception, api_url_func, client, recipe_test, mock_error): try: patch_active_data_exception(recipe_test, mock_error) url = api_url_func(recipe_test) response = client.get(url) assert response.status_code == 400 assert response.data.decode() == mock_error except Exception as e: if is_fail(recipe_test['recipe']): xfail(str(e)) else: raise e
def test_recipe_integration(recipe_name): command = ['adr', '--format', 'json'] command.extend(recipe_name.split(" ")) try: data = subprocess.check_output(command, stderr=subprocess.STDOUT) result = json.loads(data) assert result assert len(result) except Exception as e: if is_fail(command[3]): xfail(str(e)) else: raise e
def test_recipe(patch_active_data, recipe_test, validate): try: patch_active_data(recipe_test) config = Configuration() config.fmt = "json" result = json.loads( run_recipe(recipe_test['recipe'], recipe_test['args'], config)) validate(recipe_test, result) except Exception as e: if is_fail(recipe_test['recipe']): xfail(str(e)) else: raise e
def test_api(patch_active_data, api_url_func, client, recipe_test, validate): try: patch_active_data(recipe_test) url = api_url_func(recipe_test) response = client.get(url) assert response.status_code == 200 assert response.is_json actual = json.loads(response.data) validate(recipe_test, actual) except Exception as e: if is_fail(recipe_test['recipe']): xfail(str(e)) else: raise e