diff --git a/src/rkd_harbor/tasks/structure.py b/src/rkd_harbor/tasks/structure.py index d34dee0..4f269a7 100644 --- a/src/rkd_harbor/tasks/structure.py +++ b/src/rkd_harbor/tasks/structure.py @@ -44,9 +44,8 @@ def get_harbor_version_matcher() -> str: return '==' + harbor_version - - def print_success_msg(self, ctx: ExecutionContext) -> None: - super().print_success_msg(ctx) + def print_success_msg(self, use_pipenv: bool, ctx: ExecutionContext) -> None: + super().print_success_msg(use_pipenv, ctx) self.io().print_line() self.io().success_msg("Harbor successfully installed on bootstrapped RKD project, enjoy - " + "RiotKit tech collective.") diff --git a/test/test_structure_createharborstructuretask.py b/test/test_structure_createharborstructuretask.py index 4b9b360..e4e3fbc 100644 --- a/test/test_structure_createharborstructuretask.py +++ b/test/test_structure_createharborstructuretask.py @@ -2,6 +2,9 @@ import tempfile from rkd_harbor.test import BaseHarborTestClass from rkd_harbor.tasks.structure import CreateHarborStructureTask +from rkd.api.contract import ExecutionContext +from rkd.api.inputoutput import IO +from rkd.test import get_test_declaration class CreateHarborStructureTaskTest(BaseHarborTestClass): @@ -19,8 +22,10 @@ def test_functional_installation(self): os.chdir(dir_path) task = CreateHarborStructureTask() - # do not match current dev version as it may be unreleased yet when developing - task.get_harbor_version_matcher = lambda: '' + + # do not write requirements.txt in tests, we do not want to install all of those things + # as it is very problematic in development environment where things are "under construction" + task.on_requirements_txt_write = lambda ctx: None self.execute_task(task, args={ '--commit': False, @@ -37,11 +42,27 @@ def test_functional_installation(self): self.assertTrue(os.path.isfile(dir_path + '/apps/README.md'), msg='Expected that files in inner directories will be present') + finally: + os.chdir(backup_dir_path) + + def test_requirements_are_written(self): + """Verify that basic requirements list is written into requirements.txt file""" + + backup_dir_path = os.getcwd() + + try: + with tempfile.TemporaryDirectory() as dir_path: + os.chdir(dir_path) + + task = CreateHarborStructureTask() + task._io = IO() + task.on_requirements_txt_write(ExecutionContext(get_test_declaration())) + with open(dir_path + '/requirements.txt', 'rb') as requirements_txt: content = requirements_txt.read().decode('utf-8') self.assertIn('ansible>=2.8', content, msg='Expected Ansible defined in requirements.txt') - self.assertIn('rkd-harbor', content, msg='Expected rkd-harbor to be defined in requirements.txt') + self.assertIn('rkd-harbor==', content, msg='Expected rkd-harbor to be defined in requirements.txt') + finally: os.chdir(backup_dir_path) -