Skip to content

Commit

Permalink
chore: fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Chezka109 committed Oct 31, 2024
1 parent a2f26a9 commit c460df0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
16 changes: 12 additions & 4 deletions gatorgrade/input/parse_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,22 @@ def parse_config(file: Path, check_include: str = None, check_exclude: str = Non
# Filter the reformat_yaml_data to only include specified checks
if check_include:
# Generate the checks that are included
check_list = [check for check in reformatted_yaml_data if fuzz.partial_ratio(check_include, check[1]['description']) >= 80]
match = True if len(check_list) > 0 else False
check_list = [
check
for check in reformatted_yaml_data
if fuzz.partial_ratio(check_include, check[1]["description"]) >= 80
]
match = True if len(check_list) > 0 else False
parse_con = generate_checks(check_list)
return (parse_con, match)
return (parse_con, match)

if check_exclude:
# Generate the checks that are excluded
check_list = [check for check in reformatted_yaml_data if fuzz.partial_ratio(check_exclude, check[1]['description']) < 80]
check_list = [
check
for check in reformatted_yaml_data
if fuzz.partial_ratio(check_exclude, check[1]["description"]) < 80
]
match = True if len(check_list) > 0 else False
parse_con = generate_checks(check_list)
return (parse_con, match)
Expand Down
25 changes: 18 additions & 7 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,32 @@ def test_full_integration_creates_valid_output(
for output, freq in expected_output_and_freqs:
assert result.stdout.count(output) == freq


def test_default_run_invalid_output():
'''Test the default run with the assumption that the default configuration file is invalid.'''
"""Test the default run with the assumption that the default configuration file is invalid."""
result = runner.invoke(main.app)
assert result.exit_code == main.FAILURE
assert f"The file {main.FILE} either does not exist or is not valid." in result.output
assert (
f"The file {main.FILE} either does not exist or is not valid." in result.output
)


def test_specified_filename_invalid_output():
'''Test the run with a specified filename that is invalid.'''
"""Test the run with a specified filename that is invalid."""
result = runner.invoke(main.app, ["--config", "nonexistent.yml"])
assert result.exit_code == main.FAILURE
assert "The file nonexistent.yml either does not exist or is not valid." in result.output
assert (
"The file nonexistent.yml either does not exist or is not valid."
in result.output
)


def test_entry_point():
"""Test the entry point of the script to ensure it runs as expected."""
result = subprocess.run([sys.executable, "gatorgrade/main.py"], capture_output=True, text=True)
result = subprocess.run(
[sys.executable, "gatorgrade/main.py"], capture_output=True, text=True
)
assert result.returncode == main.FAILURE
assert f"The file {main.FILE} either does not exist or is not valid." in result.stdout

assert (
f"The file {main.FILE} either does not exist or is not valid." in result.stdout
)

0 comments on commit c460df0

Please sign in to comment.