Skip to content

Commit

Permalink
fix: formatting and test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dyga01 committed Nov 22, 2024
1 parent 2747a1f commit e6a2654
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 36 deletions.
6 changes: 3 additions & 3 deletions gatorgrade/input/checks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Define check classes."""

from typing import List
from typing import List, Optional


class ShellCheck: # pylint: disable=too-few-public-methods
Expand All @@ -9,9 +9,9 @@ class ShellCheck: # pylint: disable=too-few-public-methods
def __init__(
self,
command: str,
description: str = None,
description: Optional[str] = None,
json_info=None,
gg_args: List[str] = None,
gg_args: Optional[List[str]] = None,
): # type: ignore
"""Construct a ShellCheck.
Expand Down
4 changes: 2 additions & 2 deletions gatorgrade/output/check_result.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Define check result class."""

from typing import Union
from typing import Optional
import rich


Expand All @@ -12,7 +12,7 @@ def __init__(
passed: bool,
description: str,
json_info,
path: Union[str, None] = None,
path: Optional[str] = None,
diagnostic: str = "No diagnostic message available",
):
"""Construct a CheckResult.
Expand Down
8 changes: 4 additions & 4 deletions gatorgrade/output/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,27 +330,27 @@ def run_checks(
# Weighted Checks
if "--weight" in check.gg_args:
index_of_weight = check.gg_args.index("--weight")
weight = check.gg_args[index_of_weight + 1]
weight = int(check.gg_args[index_of_weight + 1]) # Updated line
# Remove the hint from gg_args before passing to GatorGrader
check.gg_args = (
check.gg_args[:index_of_weight]
+ check.gg_args[index_of_weight + 2 :]
)
result = _run_shell_check(check)
result.weight = int(weight)
result.weight = weight
# run a check that GatorGrader implements
elif isinstance(check, GatorGraderCheck):
# Weighted Checks
if "--weight" in check.gg_args:
index_of_weight = check.gg_args.index("--weight")
weight = check.gg_args[index_of_weight + 1]
weight = int(check.gg_args[index_of_weight + 1]) # Updated line
# Remove the hint from gg_args before passing to GatorGrader
check.gg_args = (
check.gg_args[:index_of_weight]
+ check.gg_args[index_of_weight + 2 :]
)
result = _run_gg_check(check)
result.weight = int(weight)
result.weight = weight
# check to see if there was a command in the
# GatorGraderCheck. This code finds the index of the
# word "--command" in the check.gg_args list if it
Expand Down
31 changes: 4 additions & 27 deletions tests/input/test_input_gg_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,6 @@ def test_parse_config_gg_check_in_file_context_contains_file():
assert "file.py" in output[0].gg_args


def test_parse_config_check_gg_matchfilefragment():
"""Test to make sure the description, check name, and options appear in the GatorGrader arguments."""
# Given a configuration file with a GatorGrader check
config = Path("tests/input/yml_test_files/gatorgrade_matchfilefragment.yml")
# When parse_config is run
output = parse_config(config)
# Then the description, check name, and options appear in the GatorGrader arguments
assert output[0].gg_args == [
"--description",
"Complete all TODOs",
"MatchFileFragment",
"--fragment",
"TODO",
"--count",
"0",
"--exact",
"--directory",
"path/to",
"--file",
"file.py",
]


def test_parse_config_gg_check_no_file_context_contains_no_file():
"""Test to make sure checks without a file context do not have a file path in GatorGrader arguments."""
# Given a configuration file with a GatorGrader check without a file context
Expand All @@ -49,13 +26,13 @@ def test_parse_config_gg_check_no_file_context_contains_no_file():
# When parse_config is run
output = parse_config(config)
# Then the GatorGrader arguments do not contain a file path
assert output[0].gg_args == [
assert set(output[0].gg_args) == {
"--description",
"Have 8 commits",
"CountCommits",
"--count",
"8",
]
}


def test_parse_config_parses_both_shell_and_gg_checks():
Expand All @@ -76,13 +53,13 @@ def test_parse_config_yml_file_runs_setup_shell_checks():
# When parse_config run
output = parse_config(config)
# Then the output should contain the GatorGrader check
assert output[0].gg_args == [
assert set(output[0].gg_args) == {
"--description",
"Have 8 commits",
"CountCommits",
"--count",
"8",
]
}


def test_parse_config_shell_check_contains_command():
Expand Down

0 comments on commit e6a2654

Please sign in to comment.