Esempio n. 1
0
def test_container_annotation_no_annotation():
    assert container_annotation(
        annotations={},
        container_name="cnt",
        pod_name="pod",
        annotation_key="foo",
        result_key="bar",
        default="def",
    ) == "def"
Esempio n. 2
0
def test_container_annotation_invalid_json():
    assert container_annotation(
        annotations={"foo": "[{]"},
        container_name="cnt",
        pod_name="pod",
        annotation_key="foo",
        result_key="bar",
        default="def",
    ) == "def"
Esempio n. 3
0
def test_container_annotation_other_container():
    assert container_annotation(
        annotations={
            "foo": json.dumps([{
                "container": "other-cnt",
                "bar": "not for us"
            }])
        },
        container_name="cnt",
        pod_name="pod",
        annotation_key="foo",
        result_key="bar",
        default="def",
    ) == "def"
Esempio n. 4
0
def test_container_annotation_not_a_list():
    assert container_annotation(
        annotations={
            "foo":
            json.dumps({
                "container": "cnt",
                "bar": {
                    "some": "data",
                    "with": ["arbitrary", "structure"]
                }
            })
        },
        container_name="cnt",
        pod_name="pod",
        annotation_key="foo",
        result_key="bar",
        default="def",
    ) == "def"
Esempio n. 5
0
def test_container_annotation_value_is_set():
    assert container_annotation(
        annotations={
            "foo":
            json.dumps([{
                "container": "cnt",
                "bar": {
                    "some": "data",
                    "with": ["arbitrary", "structure"]
                }
            }, {
                "container": "other-cnt",
                "bar": "not for us"
            }])
        },
        container_name="cnt",
        pod_name="pod",
        annotation_key="foo",
        result_key="bar",
        default="def",
    ) == {
        "some": "data",
        "with": ["arbitrary", "structure"]
    }