Commit Graph

12 Commits

Author SHA1 Message Date
Alexander Todorov
c427b772a5 Add more tests for api.recipes
- test against already existing git repository
- test commit_recipe_file() handling of IOError
- update tests for commit_recipe_directory()
  - add asserts on the existing test. Not raising an exception
    isn't enough!
  - add test which exercises the method under test while it handles
    exceptions raised by other methods
- test for list_commits() when the underlying calls fail to convert
  timestamp
- test for find_name() when `name' is not on the list
- tests for get_revision_from_tag()
2018-02-13 10:52:16 +01:00
Brian C. Lane
fe6c769349 Return the commit id for the recipe being read
This adds returning the commit id from read_commit, and a new function
read_recipe_and_id() that returns the commit id and the recipe in a
tuple.

If the commit is passed in, it is used as is. If no commit is passed in
it finds the most recent commit for the file on the selected branch and
returns that.

Missing recipes now raise a RecipeError with an informative message.
eg. "No commits for missing-recipe.toml on the master branch."
2018-02-06 16:55:14 -08:00
Brian C. Lane
a56ca875ae Add recipe_diff function and helpers.
This takes a pair of Recipe objects and returns a list of diff dicts
that include what was changed between the two recipes.
2017-11-14 16:16:48 -08:00
Brian C. Lane
baf8d7c467 Add tag_recipe_commit helper function
And change tests to use it so that both it and tag_file_commit are used.
2017-11-13 16:48:56 -08:00
Brian C. Lane
dc5a8c6fb4 Change read_recipe_commit to use the recipe name
Callers really shouldn't need to know the details of the filenames, so
change it to convert it internally.
2017-11-13 16:48:56 -08:00
Brian C. Lane
7edf6baeb4 Add revert_recipe function
And adjust the tests to use it so that it covers both revert_recipe and
revert_file.
2017-11-13 16:48:56 -08:00
Brian C. Lane
45001091be Add delete_recipe helper function and test
Use delete_recipe in the test so that both it and delete_file are
covered.
2017-11-13 16:48:56 -08:00
Brian C. Lane
053662daf0 Split recipe_from_toml into recipe_from_dict helper.
This will be useful for creating Recipe objects from json created dicts.
2017-11-13 16:44:02 -08:00
Brian C. Lane
6d71e2fcc1 Fix the recipe version bumping
Recipe should have its version bumped based on the version from the
previous commit, and not be bumped on the first commit. Fix the code and
the tests.
2017-11-13 16:44:02 -08:00
Brian C. Lane
ff47432f10 Move the git repo into a subdirectory
And fix the import of recipes (needs to have full path passed in).
2017-11-07 17:11:17 -08:00
Brian C. Lane
d2fe65c80c Fix list_commits sort order.
It appears that with libgit2 v0.24.6 reverse causes it to list them
newest first. In 0.25.1 it lists them oldest first. On both versions
just using SortMode.TIME gives the desired result of oldest first.
2017-10-25 13:31:35 -07:00
Brian C. Lane
68939a753a Add tests for the pylorax.api.recipes module 2017-10-25 13:31:35 -07:00