test(ariadne): cover Kubernetes pod selector edges
This commit is contained in:
parent
bca3d87743
commit
dc4e76c90d
@ -17,6 +17,23 @@ def test_list_pods_encodes_selector(monkeypatch) -> None:
|
||||
assert "labelSelector=app%3Dnextcloud" in captured["path"]
|
||||
|
||||
|
||||
def test_list_pods_rejects_missing_namespace() -> None:
|
||||
with pytest.raises(pods_module.PodSelectionError, match="namespace missing"):
|
||||
pods_module.list_pods(" ", "app=nextcloud")
|
||||
|
||||
|
||||
def test_parse_start_time_handles_empty_invalid_and_naive_values() -> None:
|
||||
assert pods_module._parse_start_time(None) == 0.0
|
||||
assert pods_module._parse_start_time("not-a-date") == 0.0
|
||||
assert pods_module._parse_start_time("2026-01-20T00:00:00") > 0
|
||||
|
||||
|
||||
def test_ready_helper_handles_malformed_conditions() -> None:
|
||||
assert pods_module._is_ready({"status": {"phase": "Running"}}) is False
|
||||
assert pods_module._is_ready({"status": {"phase": "Running", "conditions": [None]}}) is False
|
||||
assert pods_module._is_ready({"status": {"phase": "Running", "conditions": [{"type": "ContainersReady"}]}}) is False
|
||||
|
||||
|
||||
def test_select_pod_picks_ready_latest(monkeypatch) -> None:
|
||||
payload = {
|
||||
"items": [
|
||||
@ -57,3 +74,28 @@ def test_select_pod_ignores_non_ready(monkeypatch) -> None:
|
||||
|
||||
with pytest.raises(pods_module.PodSelectionError):
|
||||
pods_module.select_pod("demo", "app=test")
|
||||
|
||||
|
||||
def test_select_pod_skips_deleting_and_blank_names(monkeypatch) -> None:
|
||||
payload = {
|
||||
"items": [
|
||||
{
|
||||
"metadata": {"name": "deleting", "deletionTimestamp": "2026-01-20T00:00:00Z"},
|
||||
"status": {"phase": "Running", "conditions": [{"type": "Ready", "status": "True"}]},
|
||||
},
|
||||
{
|
||||
"metadata": {"name": " "},
|
||||
"status": {"phase": "Running", "conditions": [{"type": "Ready", "status": "True"}]},
|
||||
},
|
||||
{
|
||||
"metadata": {"name": "ready"},
|
||||
"status": {"phase": "Running", "nodeName": "titan-1", "conditions": [{"type": "Ready", "status": "True"}]},
|
||||
},
|
||||
]
|
||||
}
|
||||
monkeypatch.setattr(pods_module, "get_json", lambda *_args, **_kwargs: payload)
|
||||
|
||||
pod = pods_module.select_pod("demo", "app=test")
|
||||
|
||||
assert pod.name == "ready"
|
||||
assert pod.node == "titan-1"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user