Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add driver unit tests #3

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions kwait/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,21 @@ def is_ready(self) -> wait.ReadyResult:
)
return self.not_ready("replica failure")

if condition.type == "Progressing" and (
condition.status != "True"
or condition.reason != "NewReplicaSetAvailable"
):
_LOG.debug(
"%s has progressing condition: %s", self.resource, condition.message
)
return self.not_ready("progressing")
if (
condition.type == "Progressing"
and condition.status == "True"
and condition.reason == "NewReplicaSetAvailable"
) or (condition.type == "Available" and condition.status == "True"):
continue

if condition.type == "Available" and condition.status != "True":
_LOG.debug(
"%s has not finalized available condition: %s",
self.resource,
condition.message,
)
return self.not_ready("availability not finalized")
_LOG.debug(
"%s has %s condition (%s): %s",
self.resource,
condition.type,
condition.reason,
condition.message,
)
return self.not_ready(condition.type.lower())

return self.ready

Expand Down Expand Up @@ -342,7 +341,7 @@ class PodDisruptionBudget(BaseDriver):
* status.currentHealthy >= status.desiredHealthy
"""

api_version = "v1"
api_version = "policy/v1"
kind = "PodDisruptionBudget"

def __init__(
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ statefulset = "kwait.drivers:StatefulSet"

[tool.pyright]
reportPrivateImportUsage = "none"
exclude = ["kwait/drivers.py"] # TODO: kubernetes client typing seems to be very screwy?
# the kubernetes client doesn't provide type hints
# (https://github.com/kubernetes-client/python/issues/225), and I
# couldn't get any of the third-party stub packages (e.g.,
# https://pypi.org/project/kubernetes-stubs-elephant-fork/) to work.
ignore = ["kwait/drivers.py", "test/test_drivers.py"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annoying :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might consider this solution: microsoft/pyright#945
So that we can ignore the imports from that module without ignoring typing in those files altogether

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to merge this as-is and try to work on the typing stuff in a different PR to make it clearer what's happening. This looks promising though....

include = ["kwait", "test"]

[tool.pytest.ini_options]
Expand Down
Loading