def test_06_read_recipe(self): """Test reading a recipe from a commit""" commits = recipes.list_commits(self.repo, "master", "example-http-server.toml") self.assertEqual(len(commits), 1, "Wrong number of commits: %s" % commits) recipe = recipes.read_recipe_commit(self.repo, "master", "example-http-server") self.assertNotEqual(recipe, None) self.assertEqual(recipe["name"], "example-http-server") # Read by commit id recipe = recipes.read_recipe_commit(self.repo, "master", "example-http-server", commits[0].commit) self.assertNotEqual(recipe, None) self.assertEqual(recipe["name"], "example-http-server") # Read the recipe and its commit id (commit_id, recipe) = recipes.read_recipe_and_id(self.repo, "master", "example-http-server", commits[0].commit) self.assertEqual(commit_id, commits[0].commit)
def blueprint_exists(api, branch, blueprint_name): """Return True if the blueprint exists :param api: flask object :type api: Flask :param branch: Branch name :type branch: str :param recipe_name: Recipe name to read :type recipe_name: str """ try: with api.config["GITLOCK"].lock: read_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint_name) return True except (RecipeError, RecipeFileError): return False
def test_10_tag_new_commit(self): """Test tagging a newer commit of a recipe""" recipe = recipes.read_recipe_commit(self.repo, "master", "example-http-server") recipe["description"] = "A modified description" oid = recipes.commit_recipe(self.repo, "master", recipe) self.assertNotEqual(oid, None) # Tag the new commit result = recipes.tag_recipe_commit(self.repo, "master", "example-http-server") self.assertNotEqual(result, None) commits = recipes.list_commits(self.repo, "master", "example-http-server.toml") self.assertEqual(len(commits), 3, "Wrong number of commits: %s" % commits) self.assertEqual(commits[0].revision, 2)