-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_powerk8s.py
68 lines (56 loc) · 1.94 KB
/
test_powerk8s.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Unit tests for Powerk8s."""
from __future__ import annotations
import unittest
from pathlib import Path
from powerk8s import (
KUBERNETES_LOGO,
HighlightGroup,
SegmentArg,
SegmentData,
get_kubernetes_logo,
get_segment_args,
)
FILE_DIR: Path = Path(__file__).resolve().parent
class TestGetKubernetesLogo(unittest.TestCase):
"""Test getting the Kubernetes logo."""
def test_simple(self: TestGetKubernetesLogo) -> None:
"""Simple test case for getting the Kubernetes logo."""
self.assertEqual(
get_kubernetes_logo(HighlightGroup.KUBERNETES_CLUSTER.value),
SegmentData(
KUBERNETES_LOGO,
[HighlightGroup.KUBERNETES_CLUSTER.value],
HighlightGroup.KUBERNETES_DIVIDER.value,
),
)
class TestGetSegmentArgs(unittest.TestCase):
"""Test getting the segment arguments."""
def test_simple(self: TestGetSegmentArgs) -> None:
"""Test getting segment args in a simple (most obvious) case."""
self.assertEqual(
get_segment_args(
show_kube_logo=True,
show_cluster=True,
show_namespace=True,
show_default_namespace=True,
),
{
SegmentArg.SHOW_KUBERNETES_LOGO: True,
SegmentArg.SHOW_CLUSTER: True,
SegmentArg.SHOW_NAMESPACE: True,
SegmentArg.SHOW_DEFAULT_NAMESPACE: True,
},
)
def test_missing(self: TestGetSegmentArgs) -> None:
"""Test missing segment arguments."""
self.assertEqual(
get_segment_args(show_cluster=True),
{
SegmentArg.SHOW_KUBERNETES_LOGO: None,
SegmentArg.SHOW_CLUSTER: True,
SegmentArg.SHOW_NAMESPACE: None,
SegmentArg.SHOW_DEFAULT_NAMESPACE: None,
},
)
if __name__ == "__main__":
unittest.main()