Skip to content

Commit

Permalink
fix: specifying ignore comment for mypy and adding execute implementa…
Browse files Browse the repository at this point in the history
…tion to mock

fix: adapt makefile to reflect github-actions command for pre-commit

Signed-off-by: Rafael te Boekhorst <[email protected]>
  • Loading branch information
boekhorstb1 committed Jun 12, 2024
1 parent d3b713d commit 1149441
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ setup-venv:

.PHONY: run-precommit
run-precommit: ## Run pre-commit to check if all files running through
pre-commit run --all-files

pre-commit run --show-diff-on-failure --color=always --all-files

.PHONY: update-requirements
update-requirements: ## Update the requirements.txt with newer versions of pip packages
Expand Down
10 changes: 6 additions & 4 deletions tests/mock_k8s_prerequisite_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@


# Note: currently this test works with pytest but not with unittest, which is not able to import needed classes
class MockK8sPrerequisitesCheckHandler(K8sPrerequisitesCheckHandler): # type: ignore
class MockK8sPrerequisitesCheckHandler(K8sPrerequisitesCheckHandler): # type: ignore[misc]
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
# Set a mock object as the value of the k8s attribute
self._k8s = None

@property
Expand All @@ -18,7 +17,10 @@ def k8s(self, value: Any) -> None:
self._k8s = value

def preflight(self) -> None:
# Call original preflight method
super().preflight()
# Add additional mocking behavior here if needed
pass

# Note: This solves the error 'cannot instantiate abstract class "MockK8sPrerequisitesCheckHandler" with abstract attribute "execute"'
def execute(self) -> None:
super().execute()
pass

0 comments on commit 1149441

Please sign in to comment.