Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
Refactor problematic tests - no longer fetch rkd, rkd-cooperative, rk…
Browse files Browse the repository at this point in the history
…d-harbor from PIP as development dependencies could be unstable and unusable
  • Loading branch information
blackandred committed Aug 17, 2020
1 parent f763e75 commit 99c43f7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/rkd_harbor/tasks/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
29 changes: 25 additions & 4 deletions test/test_structure_createharborstructuretask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
Expand All @@ -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)

0 comments on commit 99c43f7

Please sign in to comment.