Skip to content

Commit

Permalink
Merge pull request #793 from aws-ia/revert-784-issue662
Browse files Browse the repository at this point in the history
Revert "Detect if inputfile is taskcat config or CloudFormation template, Add unittests"
  • Loading branch information
andrew-glenn authored Mar 28, 2023
2 parents c6e18a6 + 5156a0c commit 2bacda2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.9.37
current_version = 0.9.38
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.37
0.9.38
1 change: 0 additions & 1 deletion taskcat/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
18 changes: 5 additions & 13 deletions taskcat/testing/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
35 changes: 1 addition & 34 deletions tests/testing_module/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.")
Expand Down

0 comments on commit 2bacda2

Please sign in to comment.