From c77420568265b482329316723c17ff53bc63f446 Mon Sep 17 00:00:00 2001 From: Andrew Glenn <29951057+andrew-glenn@users.noreply.github.com> Date: Tue, 28 Mar 2023 16:51:09 -0500 Subject: [PATCH 1/2] Revert "Detect if inputfile is taskcat config or CloudFormation template, Add unittests" --- taskcat/_config.py | 1 - taskcat/testing/base_test.py | 18 +++++----------- tests/testing_module/test_base.py | 35 +------------------------------ 3 files changed, 6 insertions(+), 48 deletions(-) diff --git a/taskcat/_config.py b/taskcat/_config.py index 408e0880b..82c6b69f3 100644 --- a/taskcat/_config.py +++ b/taskcat/_config.py @@ -154,7 +154,6 @@ def _dict_from_file(file_path: Path, fail_ok=True) -> dict: try: with open(str(file_path), "r", encoding="utf-8") as file_handle: config_dict = yaml.safe_load(file_handle) - LOG.debug(f"file_path={file_path}, file_handle={file_handle}") return config_dict except Exception as e: # pylint: disable=broad-except LOG.warning(f"failed to load config from {file_path}") diff --git a/taskcat/testing/base_test.py b/taskcat/testing/base_test.py index fe5aecf7e..155aaff1c 100644 --- a/taskcat/testing/base_test.py +++ b/taskcat/testing/base_test.py @@ -86,19 +86,11 @@ def from_file( input_file_path: Path = project_root_path / input_file # pylint: disable=too-many-arguments args = _build_args(enable_sig_v2, regions, GLOBAL_ARGS.profile) - - # Detect if input file is taskcat config or CloudFormation template - if '.taskcat.yml' in input_file or '.taskcat.yaml' in input_file: - config = Config.create( - project_root=project_root_path, - project_config_path=input_file_path, - args=args - ) - else: - config = Config.create( - project_root=project_root_path, - template_file=input_file_path, - args=args + config = Config.create( + project_root=project_root_path, + project_config_path=input_file_path, + args=args + # TODO: detect if input file is taskcat config or CloudFormation template ) return cls(config) diff --git a/tests/testing_module/test_base.py b/tests/testing_module/test_base.py index 414d16729..5da1b8422 100644 --- a/tests/testing_module/test_base.py +++ b/tests/testing_module/test_base.py @@ -19,9 +19,6 @@ def setUpClass(cls): cls.input_file = ".taskcat.yml" cls.project_root_path = Path(__file__).parent / "../data/nested-fail" cls.input_file_path = cls.project_root_path / cls.input_file - cls.template_file = ( - Path(__file__).parent / "../data/nested-fail/templates/test.template.yaml" - ) cls.base_config = Config.create( project_root=cls.project_root_path, @@ -57,38 +54,8 @@ def test_inheritance(self): self.assertIsInstance(base, Test) - @patch("taskcat.testing.base_test._build_args") - @patch("taskcat.testing.base_test.BaseTest") - def test_from_file_template_yaml(self, base_test_mock, args_mock): - # given - mock_out = base_test_mock.return_value - - # when - mock_out.from_file( - project_root=self.project_root_path, input_file=self.template_file - ) - - # then - base_test_mock.return_value.from_file.assert_called_with( - project_root=self.project_root_path, - input_file=self.template_file - ) - - @patch("taskcat.testing.base_test._build_args") - @patch("taskcat.testing.base_test.BaseTest") - def test_from_file_taskcat_yaml(self, base_test_mock, args_mock): - # given - mock_out = base_test_mock.return_value - - # when - mock_out.from_file(project_root=self.project_root_path) - - # then - base_test_mock.return_value.from_file.assert_called_with( - project_root=self.project_root_path - ) - def test_from_file(self): + base = BaseTest.from_file(project_root=self.project_root_path) self.assertIsInstance(base, BaseTest, "Should return an instance of BaseTest.") From 5156a0cbae10136cc5502314caa983523900b8df Mon Sep 17 00:00:00 2001 From: Andrew Glenn <29951057+andrew-glenn@users.noreply.github.com> Date: Tue, 28 Mar 2023 16:52:51 -0500 Subject: [PATCH 2/2] 0.9.38 --- .bumpversion.cfg | 2 +- VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index c09c518f6..e2cb66caf 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.37 +current_version = 0.9.38 commit = False tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d+))? diff --git a/VERSION b/VERSION index 41796a924..4b38075a0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.37 +0.9.38