From 9560e75b7f20ecc6922347f1c7e19e4923dd747a Mon Sep 17 00:00:00 2001 From: nhertz <nhertz@nrao.edu> Date: Tue, 25 Aug 2020 10:53:07 -0600 Subject: [PATCH] Finished setup_to_meta tests. --- build/recipes/setup_to_meta/test/conftest.py | 2 +- .../setup_to_meta/test/test_setup_to_meta.py | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/build/recipes/setup_to_meta/test/conftest.py b/build/recipes/setup_to_meta/test/conftest.py index 542a5e9b7..8d8263525 100644 --- a/build/recipes/setup_to_meta/test/conftest.py +++ b/build/recipes/setup_to_meta/test/conftest.py @@ -2,7 +2,7 @@ import pytest import zc.buildout.testing @pytest.fixture(scope='module') -def set_up(): +def recipe(): 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 ec194d2b5..79c2b3220 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,17 +1,31 @@ import pytest +from .. import setup_to_meta class TestSetupToMeta: - def test_output(self, set_up): + def test_del_substrings(self): + replaced = setup_to_meta.del_substrings('heallob, woarlcd', ['a', 'b', 'c']) + assert replaced == 'hello, world' + + def test_get_names(self): + d = 'apps/cli/executables/null' + assert setup_to_meta.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'] + + 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 set_up: Fixture that initializes - :return: + :param recipe: Fixture that initializes recipe class in setup_to_meta.py """ - created = set_up.install() + created = recipe.install() for path in created: with open(path, 'r') as f: - assert 'package' in f.read() \ No newline at end of file + assert 'package' in f.read() -- GitLab