From c937e69d3b9f6996546221fd011362e2ae92b6e8 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 13 Nov 2017 12:20:38 -0800 Subject: [PATCH] Add delete_recipe helper function and test Use delete_recipe in the test so that both it and delete_file are covered. --- src/pylorax/api/recipes.py | 15 +++++++++++++++ tests/pylorax/test_recipes.py | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pylorax/api/recipes.py b/src/pylorax/api/recipes.py index 746c7cdc..65885f90 100644 --- a/src/pylorax/api/recipes.py +++ b/src/pylorax/api/recipes.py @@ -343,6 +343,21 @@ def list_commit_files(repo, commit): tree = commit_obj.get_tree() return sorted([tree.get(i).get_name() for i in range(0,tree.size())]) +def delete_recipe(repo, branch, recipe_name): + """Delete a recipe from a branch. + + :param repo: Open repository + :type repo: Git.Repository + :param branch: Branch name + :type branch: str + :param recipe_name: Recipe name to delete + :type recipe_name: str + :returns: OId of the new commit + :rtype: Git.OId + :raises: Can raise errors from Ggit + """ + return delete_file(repo, branch, recipe_filename(recipe_name)) + def delete_file(repo, branch, filename): """Delete a file from a branch. diff --git a/tests/pylorax/test_recipes.py b/tests/pylorax/test_recipes.py index 825d6a31..fc935763 100644 --- a/tests/pylorax/test_recipes.py +++ b/tests/pylorax/test_recipes.py @@ -174,7 +174,7 @@ class GitRecipesTest(unittest.TestCase): def test_08_delete_recipe(self): """Test deleting a file from a branch""" - oid = recipes.delete_file(self.repo, "master", "http-server.toml") + oid = recipes.delete_recipe(self.repo, "master", "http-server") self.assertNotEqual(oid, None) master_files = recipes.list_branch_files(self.repo, "master")