Skip to content

Commit

Permalink
Fix tests after type fixes. Add tests to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-flinn committed Jan 12, 2024
1 parent 4ca8b81 commit f263128
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/lint-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,11 @@ jobs:
- name: Test lint
working-directory: lint-workflow-v2
run: pipenv run pytest tests --cov=src

- name: Check type hinting
working-directory: lint-workflow-v2
run: pipenv run pytype src

- name: Simple end-to-end testing
working-directory: lint-workflow-v2
run: pipenv run python cli.py -v lint --files tests/fixtures/test.yml
4 changes: 3 additions & 1 deletion lint-workflow-v2/src/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def __init__(self, settings: Optional[Settings] = None) -> None:
self.settings = settings

@staticmethod
def extend_parser(subparsers: argparse._SubParsersAction) -> argparse._SubParsersAction:
def extend_parser(
subparsers: argparse._SubParsersAction,
) -> argparse._SubParsersAction:
"""Extends the CLI subparser with the options for ActionCmd.
Add 'actions add' and 'actions update' to the CLI as sub-commands
Expand Down
4 changes: 3 additions & 1 deletion lint-workflow-v2/src/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def __init__(self, settings: Optional[Settings] = None) -> None:
self.rules = Rules(settings=settings)

@staticmethod
def extend_parser(subparsers: argparse._SubParsersAction) -> argparse._SubParsersAction:
def extend_parser(
subparsers: argparse._SubParsersAction,
) -> argparse._SubParsersAction:
"""Extends the CLI subparser with the options for LintCmd.
Add 'lint' as a sub command along with its options and arguments
Expand Down
2 changes: 1 addition & 1 deletion lint-workflow-v2/src/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def build(
cls,
filename: Optional[str] = None,
workflow: Optional[CommentedMap] = None,
from_file: bool = True
from_file: bool = True,
) -> Workflow:
"""Build a Workflow from either code or a file.
Expand Down
6 changes: 1 addition & 5 deletions lint-workflow-v2/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ class LintLevels(LintLevel, Enum):
class LintFinding:
"""Represents a problem detected by linting."""

def __init__(
self,
description: str,
level: LintLevels
) -> None:
def __init__(self, description: str, level: LintLevels) -> None:
self.description = description
self.level = level

Expand Down
17 changes: 10 additions & 7 deletions lint-workflow-v2/tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,30 @@ def test_get_max_error_level(settings):
assert (
linter.get_max_error_level(
[
LintFinding(level=LintLevels.WARNING),
LintFinding(level=LintLevels.WARNING),
LintFinding(description="", level=LintLevels.WARNING),
LintFinding(description="", level=LintLevels.WARNING),
]
)
== 1
)

assert (
linter.get_max_error_level(
[LintFinding(level=LintLevels.ERROR), LintFinding(level=LintLevels.ERROR)]
[
LintFinding(description="", level=LintLevels.ERROR),
LintFinding(description="", level=LintLevels.ERROR),
]
)
== 2
)

assert (
linter.get_max_error_level(
[
LintFinding(level=LintLevels.ERROR),
LintFinding(level=LintLevels.ERROR),
LintFinding(level=LintLevels.WARNING),
LintFinding(level=LintLevels.WARNING),
LintFinding(description="", level=LintLevels.ERROR),
LintFinding(description="", level=LintLevels.ERROR),
LintFinding(description="", level=LintLevels.WARNING),
LintFinding(description="", level=LintLevels.WARNING),
]
)
== 2
Expand Down
4 changes: 2 additions & 2 deletions lint-workflow-v2/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_lint_level():


def test_lint_finding():
warning = LintFinding(level=LintLevels.WARNING)
warning = LintFinding(description="<no description>", level=LintLevels.WARNING)
assert str(warning) == "\x1b[33mwarning\x1b[0m <no description>"

error = LintFinding(level=LintLevels.ERROR)
error = LintFinding(description="<no description>", level=LintLevels.ERROR)
assert str(error) == "\x1b[31merror\x1b[0m <no description>"

0 comments on commit f263128

Please sign in to comment.