Skip to content

Commit

Permalink
Add raise in terms of wrong datatype
Browse files Browse the repository at this point in the history
  • Loading branch information
philnewm committed Sep 30, 2024
1 parent c06979a commit 5e45bb5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion github_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def pr_labels(latest_release_date, query_tags, repo_name):
def version_increment(latest_release_date, query_tags, repo_name):
"""Output a calculated version increment suggestion.
latest_release_date (str): datatime string\n
latest_release_date (str): datetime string\n
query_tags (str): csv string\n
repo_name (str): repo name as <owner><repo>\n
"""
Expand Down
4 changes: 4 additions & 0 deletions src/conversion_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ def get_version_increment(pr_label_list: list, patch_bump_list: list=[], minor_b
logger.warning("PR label list was empty")
return ""

for name, param in locals().items():
if not isinstance(param, list):
raise ValueError(f"{name} must be a list.")

if any(label in pr_label_list for label in major_bump_list):
return "major"

Expand Down
13 changes: 13 additions & 0 deletions tests/test_github_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def pr_api_output_missing_label():
def major_bump():
return ["epic"]

@pytest.fixture
def major_bump_no_list():
return "epic"

@pytest.fixture
def minor_bump():
return ["feature", "enhancement"]
Expand Down Expand Up @@ -206,3 +210,12 @@ def test_get_version_increment_empty_list(minor_bump, patch_bump, pr_labels_empt
)

assert increment == ""

def test_get_version_increment_no_list(minor_bump, patch_bump, major_bump_no_list, pr_labels_epic):
with pytest.raises(ValueError, match="must be a list"):
conversion_logic.get_version_increment(
pr_label_list=pr_labels_epic,
patch_bump_list=patch_bump,
minor_bump_list=minor_bump,
major_bump_list=major_bump_no_list,
)

0 comments on commit 5e45bb5

Please sign in to comment.