diff --git a/build/recipes/build_pkgs/test/__init__.py b/build/recipes/build_pkgs/test/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/build/recipes/build_pkgs/test/conftest.py b/build/recipes/build_pkgs/test/conftest.py index 8d8263525cd21960b13684aeb7f0019c6ba0671c..e98638c7ae9666bdb27979cbb8e20c1f899271b8 100644 --- a/build/recipes/build_pkgs/test/conftest.py +++ b/build/recipes/build_pkgs/test/conftest.py @@ -3,8 +3,14 @@ import zc.buildout.testing @pytest.fixture(scope='module') def recipe(): - from .. import setup_to_meta + """ + pytest fixture that initializes zc.buildout objects for use in testing. + Initializes Buildout, Options, and Recipe objects. + + :return: Initialized recipe object for build_pkgs + """ + from .. import build_pkgs buildout = zc.buildout.testing.Buildout() - options = buildout.Options(buildout, 'gen_metadata', {'recipe': 'setup_to_meta'}) - recipe = setup_to_meta.Recipe(buildout=buildout, name=None, options=options) + options = buildout.Options(buildout, 'build_pkgs', {'recipe': 'build_pkgs', 'name': 'null'}) + recipe = build_pkgs.Recipe(buildout=buildout, name=None, options=options) return recipe \ No newline at end of file diff --git a/build/recipes/build_pkgs/test/test_build_pkgs.py b/build/recipes/build_pkgs/test/test_build_pkgs.py index 79c2b3220dc6e4bdb4ab908385553dc3cb40bacf..c0dfae66cbebc4a4540506aff006532ed8a15497 100644 --- a/build/recipes/build_pkgs/test/test_build_pkgs.py +++ b/build/recipes/build_pkgs/test/test_build_pkgs.py @@ -1,31 +1,30 @@ -import pytest -from .. import setup_to_meta - -class TestSetupToMeta: - def test_del_substrings(self): - replaced = setup_to_meta.del_substrings('heallob, woarlcd', ['a', 'b', 'c']) - assert replaced == 'hello, world' +import os +from .. import build_pkgs +class TestBuildPkgs: def test_get_names(self): + """ + Test that build_pkgs correctly gets the package name from + :return: + """ d = 'apps/cli/executables/null' - assert setup_to_meta.get_names([d]) == ['null'] + assert build_pkgs.get_names([d]) == ['null'] def test_get_dirs(self): - assert './apps/cli/executables/null' in setup_to_meta.get_dirs() - - def test_get_outputs(self): - assert setup_to_meta.get_outputs(['null']) == ['build/metadata/null/meta.yaml'] + """ + Test that build_pkgs correctly finds and stores directory paths + of directories containing setup.py files. + """ + assert './apps/cli/executables/null' in build_pkgs.get_dirs() def test_output(self, recipe): """ - Test that metadata was successfully created and contains data. - - Checking for 'package' is an arbitrary check for content that will always - occur in a correct recipe. - :param recipe: Fixture that initializes recipe class in setup_to_meta.py + Test that the package specified in the recipe has been built correctly. """ created = recipe.install() for path in created: - with open(path, 'r') as f: - assert 'package' in f.read() + print(path) + if len(path) > 0: + assert path is not None, "conda build failed to build package" + assert os.path.exists(path) diff --git a/build/recipes/setup_to_meta/test/__init__.py b/build/recipes/setup_to_meta/test/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/build/recipes/setup_to_meta/test/conftest.py b/build/recipes/setup_to_meta/test/conftest.py index 8d8263525cd21960b13684aeb7f0019c6ba0671c..2f6dfb21d3d7ca162dc8b378bf4be2ce707f77ab 100644 --- a/build/recipes/setup_to_meta/test/conftest.py +++ b/build/recipes/setup_to_meta/test/conftest.py @@ -3,6 +3,12 @@ import zc.buildout.testing @pytest.fixture(scope='module') def recipe(): + """ + pytest fixture that initializes zc.buildout objects for use in testing. + Initializes Buildout, Options, and Recipe objects. + + :return: Initialized recipe object for setup_to_meta + """ from .. import setup_to_meta buildout = zc.buildout.testing.Buildout() options = buildout.Options(buildout, 'gen_metadata', {'recipe': 'setup_to_meta'}) diff --git a/build/recipes/setup_to_meta/test/test_setup_to_meta.py b/build/recipes/setup_to_meta/test/test_setup_to_meta.py index 79c2b3220dc6e4bdb4ab908385553dc3cb40bacf..dc6a201f942406e8e380f6405be831412a23b618 100644 --- a/build/recipes/setup_to_meta/test/test_setup_to_meta.py +++ b/build/recipes/setup_to_meta/test/test_setup_to_meta.py @@ -1,19 +1,32 @@ -import pytest from .. import setup_to_meta class TestSetupToMeta: def test_del_substrings(self): + """ + Test that del_substrings function properly deletes substrings from a given string + """ replaced = setup_to_meta.del_substrings('heallob, woarlcd', ['a', 'b', 'c']) assert replaced == 'hello, world' def test_get_names(self): + """ + Test that setup_to_meta correctly gets the package name from the package path + """ d = 'apps/cli/executables/null' assert setup_to_meta.get_names([d]) == ['null'] def test_get_dirs(self): + """ + Test that setup_to_meta correctly finds and stores directory paths + of packages containing setup.py files + """ assert './apps/cli/executables/null' in setup_to_meta.get_dirs() def test_get_outputs(self): + """ + Test that tests that setup_to_meta correctly generates a list of output paths given + a list of package names. + """ assert setup_to_meta.get_outputs(['null']) == ['build/metadata/null/meta.yaml'] def test_output(self, recipe): diff --git a/build/recipes/test_recipes/test/__init__.py b/build/recipes/test_recipes/test/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/build/recipes/test_recipes/test/test_test_recipes.py b/build/recipes/test_recipes/test/test_test_recipes.py index 788ef92177c924efa230fbcad259d2182dd9234a..57034eefdff357e8e0b09ddb02c556b57b0f2fff 100644 --- a/build/recipes/test_recipes/test/test_test_recipes.py +++ b/build/recipes/test_recipes/test/test_test_recipes.py @@ -6,7 +6,7 @@ class TestRecipes: Test that test_recipes is able to successfully retrieve names and paths for all buildout recipes. """ - recipe_names = ['setup_to_meta', 'build_packages', 'test_recipes'] + recipe_names = ['setup_to_meta', 'build_pkgs', 'test_recipes'] recipes = test_recipes.get_recipes() for recipe in recipe_names: assert recipe in recipes diff --git a/build/recipes/test_recipes/test_recipes.py b/build/recipes/test_recipes/test_recipes.py index a66e349ee5eeb0260c27db2d2a8204de0ed3683d..479cc05141ca024ae4db3a58f36ebf6f570100d2 100644 --- a/build/recipes/test_recipes/test_recipes.py +++ b/build/recipes/test_recipes/test_recipes.py @@ -32,6 +32,16 @@ class Recipe: For more detailed information, see the link. http://www.buildout.org/en/latest/topics/writing-recipes.html """ + + def run_test(self, recipe): + """ + Run test for given recipe. + :param recipe: Name of recipe to be run. + """ + logger.debug(f"Running tests for recipe {recipe}...") + subprocess.run(['pytest', '-vv', '--log-level=DEBUG', '--showlocals', + self.recipes[recipe]]) + def __init__(self, buildout, name, options): """ Initializes fields needed for recipe. @@ -52,7 +62,10 @@ class Recipe: In this case, nothing is "installed" per se. :return: Paths to files, as strings, created by the recipe. """ - if self.choice in self.recipes: - logger.debug(f"Running tests for recipe {self.choice}...") - subprocess.run(['pytest', '-vv', '--log-level=DEBUG', '--showlocals', - self.recipes[self.choice]]) + if self.choice == 'all': + # Run tests for all recipes + for recipe in self.recipes: + self.run_test(recipe) + else: + if self.choice in self.recipes: + self.run_test(self.choice) \ No newline at end of file