Skip to content

Commit

Permalink
Update tests to cover nonetypes for pr_label_list
Browse files Browse the repository at this point in the history
  • Loading branch information
philnewm committed Sep 10, 2024
1 parent e49015e commit 05ebaa2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions github_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ def get_version_increment(patch_bump_list: list, minor_bump_list: list, pr_label
Returns:
str: version increment
"""

if not pr_label_list:
return

# TODO add major bump option
if any(label in pr_label_list for label in minor_bump_list):
return "minor"
Expand Down
22 changes: 20 additions & 2 deletions tests/test_github_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,17 @@ def pr_labels_enhancement():
return ["bugfix", "documentation", "feature", "enhancement"]

@pytest.fixture
def pr_labels_none():
def pr_labels_wrong_labels():
return ["documentation", "wontfix"]

@pytest.fixture
def pr_labels_empty_list():
return []

@pytest.fixture
def pr_labels_none():
return None


# Get PR Label test-cases

Expand All @@ -82,7 +90,7 @@ def test_get_labels(pr_api_output):
assert isinstance(labels, list)
assert set(labels) == {"bugfix", "enhancement"}

def test_get_labels_missign_input(pr_api_output_missing_label):
def test_get_labels_missing_input(pr_api_output_missing_label):
labels = github_query.get_labels(pr_data=pr_api_output_missing_label)

assert labels == None
Expand All @@ -100,7 +108,17 @@ def test_get_version_increment_minor(minor_bump, patch_bump, pr_labels_enhanceme

assert increment == "minor"

def test_get_version_increment_wrong_labels(minor_bump, patch_bump, pr_labels_wrong_labels):
increment = github_query.get_version_increment(patch_bump_list=patch_bump, minor_bump_list=minor_bump, pr_label_list=pr_labels_wrong_labels)

assert increment == None

def test_get_version_increment_none(minor_bump, patch_bump, pr_labels_none):
increment = github_query.get_version_increment(patch_bump_list=patch_bump, minor_bump_list=minor_bump, pr_label_list=pr_labels_none)

assert increment == None

def test_get_version_increment_ampty_list(minor_bump, patch_bump, pr_labels_empty_list):
increment = github_query.get_version_increment(patch_bump_list=patch_bump, minor_bump_list=minor_bump, pr_label_list=pr_labels_empty_list)

assert increment == None

0 comments on commit 05ebaa2

Please sign in to comment.