Skip to content
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

Generate tmt_context by generate_tmt_vars.py #53

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
tests/copr_artifacts
tests/secrets
tests/variables
tests/tmt_context
2 changes: 1 addition & 1 deletion generate_tmt_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
output_name = ""
if len(sys.argv) == 2:
output_name = sys.argv[1]
if output_name != "variables" and output_name != "secrets":
if output_name != "variables" and output_name != "secrets" and output_name != "tmt_context":
sys.exit(1)

if len(sys.argv) > 2:
Expand Down
22 changes: 22 additions & 0 deletions tests/test_tmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ def test_tmt_variables_missing_second_parameter():
assert json_string == expected


def test_tmt_context_missing_second_parameter():
expected = {}
output_name = "tmt_context"
ret_val = subprocess.call(f"python3 {TESTDIR}/../generate_tmt_vars.py \"{output_name}\"", shell=True)
assert ret_val == 0
with open(output_name, "r") as f:
data = f.read()
json_string = json.loads(data)
assert json_string == expected


def test_tmt_variables_one_parameter():
expected = {"data": "123"}
output_name = "variables"
Expand All @@ -64,6 +75,17 @@ def test_tmt_variables_one_parameter():
assert json_string == expected


def test_tmt_context_one_parameter():
expected = {"data": "123"}
output_name = "tmt_context"
ret_val = subprocess.call(f"python3 {TESTDIR}/../generate_tmt_vars.py \"{output_name}\" \"data=123\"", shell=True)
assert ret_val == 0
with open(output_name, "r") as f:
data = f.read()
json_string = json.loads(data)
assert json_string == expected


def test_tmt_variables_two_variable():
expected = {"data": "123", "second": "987"}
output_name = "variables"
Expand Down