generated from Sceptre/sceptre-template-handler-template
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(test_cdk.py): potential fix for failing tests #22
Open
ericabrauer
wants to merge
3
commits into
main
Choose a base branch
from
cdk-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,15 +278,20 @@ def fake_subprocess_run(self, command, *, env, shell, stdout, check, cwd): | |
self.assertTrue(shell) | ||
self.assertTrue(check) | ||
self.assertIs(sys.stderr, stdout) | ||
parser = argparse.ArgumentParser(prog="npx", exit_on_error=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
parser = argparse.ArgumentParser(prog="npx") | ||
|
||
if command.startswith("npx cdk-assets"): | ||
if self.raise_assets_error: | ||
raise subprocess.CalledProcessError(1, "bad command") | ||
self.subprocess_envs["assets"] = env | ||
parser.add_argument("--path") | ||
parsed, _ = parser.parse_known_args(command.split(" ")) | ||
self.assertTrue(Path(parsed.path).exists()) | ||
try: | ||
parsed, _ = parser.parse_known_args(command.split(" ")) | ||
self.assertTrue(Path(parsed.path).exists()) | ||
except SystemExit: | ||
raise subprocess.CalledProcessError(1, "bad command") | ||
self.artifacts_published = True | ||
|
||
elif command.startswith("npx cdk synth"): | ||
if self.raise_synth_error: | ||
raise subprocess.CalledProcessError(1, "bad command") | ||
|
@@ -298,19 +303,26 @@ def fake_subprocess_run(self, command, *, env, shell, stdout, check, cwd): | |
parser.add_argument("stack_logical_id") | ||
parser.add_argument("-o", "--output") | ||
parser.add_argument("--context", action="append") | ||
parsed, _ = parser.parse_known_args(command.split(" ")) | ||
self.synth_context = { | ||
key: value | ||
for key, value in [context.split("=") for context in parsed.context] | ||
} | ||
assets_file = Path(parsed.output, f"{parsed.stack_logical_id}.assets.json") | ||
template_file = Path( | ||
parsed.output, f"{parsed.stack_logical_id}.template.json" | ||
) | ||
self.fs.create_file(str(assets_file), contents=json.dumps(self.manifest)) | ||
self.fs.create_file( | ||
str(template_file), contents=json.dumps(self.expected_template) | ||
) | ||
try: | ||
parsed, _ = parser.parse_known_args(command.split(" ")) | ||
self.synth_context = { | ||
key: value | ||
for key, value in [context.split("=") for context in parsed.context] | ||
} | ||
assets_file = Path( | ||
parsed.output, f"{parsed.stack_logical_id}.assets.json" | ||
) | ||
template_file = Path( | ||
parsed.output, f"{parsed.stack_logical_id}.template.json" | ||
) | ||
self.fs.create_file( | ||
str(assets_file), contents=json.dumps(self.manifest) | ||
) | ||
self.fs.create_file( | ||
str(template_file), contents=json.dumps(self.expected_template) | ||
) | ||
except SystemExit: | ||
raise subprocess.CalledProcessError(1, "bad command") | ||
|
||
def test_build_template__sceptre_user_data_specified__logs_warning(self): | ||
self.builder.build_template(self.context, self.sceptre_user_data) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you remove
assert_called_once_with
in these tests you might as well remove the entireself.bootstrapped_builder_class
call.i think @jfalkenstein is intentionally doing an explicit check here and it seems like it should pass because the expected and actual are the exact same in the test error message..
I can't figure out why it's failing when expected and actual are the same. I tried searching the internet for some clues but didn't find anything helpful 😞