Skip to content

Commit

Permalink
chore: implemented fix for #40
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancheley committed Dec 12, 2021
1 parent a99c891 commit 69e2374
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 26 deletions.
8 changes: 0 additions & 8 deletions src/the_well_maintained_test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ def _get_release_date(release: dict) -> List:
return releases


def _check_verb_agreement(count: int) -> str:
if count == 1:
verb = "is"
else:
verb = "are"
return verb


def _get_requirements_txt_file(requirements_file: Path) -> List:
with open(requirements_file) as f:
requirements = f.readlines()
Expand Down
8 changes: 4 additions & 4 deletions src/the_well_maintained_test/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import re
from datetime import datetime
from gettext import ngettext
from operator import attrgetter
from pathlib import Path
from time import localtime, strftime
Expand All @@ -11,7 +12,6 @@

from the_well_maintained_test.console import console
from the_well_maintained_test.helpers import (
_check_verb_agreement,
_get_bug_comment_list,
_get_content,
_get_release_date,
Expand Down Expand Up @@ -81,7 +81,7 @@ def bug_responding(bugs_url: str, headers: dict) -> str:
message2 = f"It has been {days_since_last_bug_comment} days since a comment was made on the bug."
message = f"[green]{message1}\n{message2}"
else:
verb = _check_verb_agreement(open_bug_count)
verb = ngettext("is", "are", open_bug_count)
message = f"[red]There {verb} {open_bug_count} bugs with no comments"
return message

Expand All @@ -106,7 +106,7 @@ def check_tests(tree_url: str, headers: dict, show_progress: bool = True) -> str
if test_files == 0:
message = "[red]There are 0 tests!"
else:
verb = _check_verb_agreement(test_functions)
verb = ngettext("is", "are", test_functions)
message = f"[green]There {verb} {test_functions} tests in {test_files} files:\n"
for test in test_list:
message += f"- {test.get('path')}\n"
Expand Down Expand Up @@ -149,7 +149,7 @@ def ci_setup(workflows_url: str, headers: dict) -> str:
r = requests.get(workflows_url, headers=headers).json()
if r.get("total_count") > 0:
workflow_count = r.get("total_count")
verb = _check_verb_agreement(workflow_count)
verb = ngettext("is", "are", workflow_count)
message = f"[green]There {verb} {workflow_count} workflows\n"
for i in r.get("workflows"):
message += f"[green]- {i.get('name')}\n"
Expand Down
14 changes: 0 additions & 14 deletions tests/test_the_well_maintained_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
)
from the_well_maintained_test.cli import cli
from the_well_maintained_test.helpers import (
_check_verb_agreement,
_get_package_github_url,
_get_requirements_txt_file,
)
Expand Down Expand Up @@ -777,19 +776,6 @@ def test__get_release_date_missing():
assert actual == expected


@pytest.mark.parametrize(
"test_input,expected",
[
[0, "are"],
[1, "is"],
[2, "are"],
[-1, "are"],
],
)
def test__check_verb_agreement(test_input, expected):
assert _check_verb_agreement(test_input) == expected


def test__get_requirements_txt_file(tmpdir, monkeypatch):
def mock_get(*args, **kwargs):
return MockResponseProjectURLs()
Expand Down

0 comments on commit 69e2374

Please sign in to comment.