Skip to content

Commit

Permalink
fix: review app yml created in source code dir causing coverage to error
Browse files Browse the repository at this point in the history
  • Loading branch information
artsyjian committed Aug 18, 2023
1 parent fc67e35 commit 9b44073
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/integration/test_review_app.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import os
import httpretty
import os
import sys

from unittest.mock import patch

from test import HokusaiIntegrationTestCase, TEST_KUBE_CONTEXT
from test.utils import captured_output
from test.mocks.mock_ecr import MockECR

import hokusai.commands.namespace

from hokusai import CWD
from hokusai.lib.common import shout
from hokusai.commands import kubernetes
from hokusai.commands.namespace import create_new_app_yaml
from hokusai.lib.common import shout
Expand All @@ -17,10 +18,10 @@
class TestReviewApp(HokusaiIntegrationTestCase):
@classmethod
def setUpClass(cls):
kubernetes.ECR = MockECR
kubernetes.HOKUSAI_CONFIG_DIR = os.path.join(CWD, 'test/fixtures/project/hokusai')
cls.kubernetes_yml = os.path.abspath(os.path.join(kubernetes.HOKUSAI_CONFIG_DIR, 'a-review-app.yml'))
cls.kctl = Kubectl(TEST_KUBE_CONTEXT)
config_dir = 'test/fixtures/project/hokusai'
cls.HOKUSAI_CONFIG_DIR = config_dir
hokusai.commands.namespace.HOKUSAI_CONFIG_DIR = config_dir

@classmethod
def tearDownClass(cls):
Expand All @@ -37,9 +38,10 @@ def test_create_review_app_yaml_file(self, mocked_sys_exit):
body=self.fixture('ecr-repositories-response.json'),
content_type="application/x-amz-json-1.1")

review_app_yaml_file = os.path.join(CWD, 'hokusai', 'a-review-app.yml')
review_app_yaml_file = os.path.join(CWD, self.__class__.HOKUSAI_CONFIG_DIR, 'a-review-app.yml')
try:
create_new_app_yaml(os.path.abspath(os.path.join(CWD, 'test/fixtures/project/hokusai/minikube.yml')), 'a-review-app')
create_new_app_yaml(os.path.join(CWD, self.__class__.HOKUSAI_CONFIG_DIR, 'minikube.yml'), 'a-review-app')
mocked_sys_exit.assert_called_once_with(0)
self.assertTrue(os.path.isfile(review_app_yaml_file))
finally:
os.remove(review_app_yaml_file)
Expand All @@ -54,10 +56,10 @@ def test_01_k8s_create(self, mocked_sys_exit):
body=self.fixture('ecr-repositories-response.json'),
content_type="application/x-amz-json-1.1")

review_app_yaml_file = os.path.join(CWD, 'hokusai', 'a-review-app.yml')
review_app_yaml_file = os.path.join(CWD, self.__class__.HOKUSAI_CONFIG_DIR, 'a-review-app.yml')
with captured_output() as (out, err):
try:
create_new_app_yaml(os.path.abspath(os.path.join(CWD, 'test/fixtures/project/hokusai/minikube.yml')), 'a-review-app')
create_new_app_yaml(os.path.join(CWD, self.__class__.HOKUSAI_CONFIG_DIR, 'minikube.yml'), 'a-review-app')
mocked_sys_exit.assert_called_once_with(0)
mocked_sys_exit.reset_mock()
kubernetes.k8s_create(TEST_KUBE_CONTEXT, filename=review_app_yaml_file)
Expand Down

0 comments on commit 9b44073

Please sign in to comment.