-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
ModuleHandler
mock for module k8s_prerequisites_check
Signed-off-by: Tobias Wolf <[email protected]>
- Loading branch information
1 parent
b07f7d9
commit b758793
Showing
3 changed files
with
18 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from rookify.modules.k8s_prerequisites_check.main import K8sPrerequisitesCheckHandler | ||
from typing import Any | ||
from .mock_k8s import MockK8s | ||
|
||
|
||
# Note: currently this test works with pytest but not with unittest, which is not able to import needed classes | ||
class MockK8sPrerequisitesCheckHandler(K8sPrerequisitesCheckHandler): | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: | ||
super().__init__(*args, **kwargs) | ||
self._k8s = None | ||
|
||
@property | ||
def k8s(self) -> Any: | ||
return self._k8s | ||
|
||
@k8s.setter | ||
def k8s(self, value: Any) -> None: | ||
self._k8s = value | ||
|
||
def preflight(self) -> None: | ||
super().preflight() | ||
pass | ||
def __init__(self, request_callback: Any, *args: Any, **kwargs: Any) -> None: | ||
K8sPrerequisitesCheckHandler.__init__(self, *args, **kwargs) | ||
self._k8s = MockK8s(request_callback) # type: ignore | ||
|
||
# Note: This solves the error 'cannot instantiate abstract class "MockK8sPrerequisitesCheckHandler" with abstract attribute "execute"' | ||
def execute(self) -> None: | ||
super().execute() | ||
pass | ||
K8sPrerequisitesCheckHandler.execute(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters