Beispiel #1
0
def test_update():
    pod = Pod(
        None, {
            'metadata': {
                'name': 'john',
                'kind': 'test'
            },
            'annotations': 'a long string'
        })
    pod.obj = {'metadata': {'name': 'john'}}
    pod.api = MagicMock()
    pod.api.patch.return_value.json.return_value = obj_merge(
        pod.obj, pod._original_obj, False)
    pod.update(is_strategic=False)
    assert pod.metadata == {'name': 'john'}
    assert pod.annotations == {}
Beispiel #2
0
def test_update():
    pod = Pod(
        None,
        {
            "metadata": {
                "name": "john",
                "kind": "test"
            },
            "annotations": "a long string"
        },
    )
    pod.obj = {"metadata": {"name": "john"}}
    pod.api = MagicMock()
    pod.api.patch.return_value.json.return_value = obj_merge(
        pod.obj, pod._original_obj, False)
    pod.update(is_strategic=False)
    assert pod.metadata == {"name": "john"}
    assert pod.annotations == {}
Beispiel #3
0
def test_obj_merge():
    assert obj_merge({}, {}) == {}
    assert obj_merge({"a": 1}, {}) == {"a": 1}
    assert obj_merge({}, {"b": 2}) == {"b": 2}
    assert obj_merge({"a": []}, {"a": []}) == {"a": []}
    assert obj_merge({"a": [1, 2]}, {"a": []}) == {"a": [1, 2]}
    assert obj_merge({"a": []}, {"a": [1, 2]}) == {"a": [1, 2]}
    assert obj_merge({"a": [1, 2]}, {"a": [3, 4]}) == {"a": [1, 2]}
    assert obj_merge({"a": {"b": [1, 2]}}, {"a": {"b": [3, 4, 5], "c": [1, 2]}}) == {
        "a": {"b": [1, 2, 5], "c": [1, 2]}
    }

    assert obj_merge(
        {"a": {"e": [1, 2], "f": [5, 6]}},
        {"a": {"e": [3, 4]}, "b": ["1"]},
        is_strategic=False,
    ) == {"a": {"e": [1, 2], "f": [5, 6]}}
    assert obj_merge({"a": []}, {"a": [1, 2]}, is_strategic=False) == {"a": []}
    assert obj_merge({"a": {"b": [1, 2]}}, {"a": [1, 2]}, is_strategic=False) == {
        "a": {"b": [1, 2]}
    }
    assert obj_merge(
        {"a": {"b": [1, 2]}}, {"a": {"b": [], "c": [1, 2]}}, is_strategic=False
    ) == {"a": {"b": [1, 2]}}
    assert obj_merge(
        {"a": {"b": [1, 2]}}, {"a": {"b": [3, 4, 5], "c": [1, 2]}}, is_strategic=False
    ) == {"a": {"b": [1, 2]}}
Beispiel #4
0
 def update(self):
     print("Mocked update")
     self.obj = obj_merge(self.obj, self._original_obj)
Beispiel #5
0
def test_obj_merge():
    assert obj_merge({}, {}) == {}
    assert obj_merge({'a': 1}, {}) == {'a': 1}
    assert obj_merge({}, {'b': 2}) == {'b': 2}
    assert obj_merge({'a': []}, {'a': []}) == {'a': []}
    assert obj_merge({'a': [1, 2]}, {'a': [3, 4]}) == {'a': [1, 2]}
Beispiel #6
0
def test_obj_merge():
    assert obj_merge({}, {}) == {}
    assert obj_merge({'a': 1}, {}) == {'a': 1}
    assert obj_merge({}, {'b': 2}) == {'b': 2}
    assert obj_merge({'a': []}, {'a': []}) == {'a': []}
    assert obj_merge({'a': [1, 2]}, {'a': []}) == {'a': [1, 2]}
    assert obj_merge({'a': []}, {'a': [1, 2]}) == {'a': [1, 2]}
    assert obj_merge({'a': [1, 2]}, {'a': [3, 4]}) == {'a': [1, 2]}
    assert obj_merge({'a': {
        'b': [1, 2]
    }}, {'a': {
        'b': [3, 4, 5],
        'c': [1, 2]
    }}) == {
        'a': {
            'b': [1, 2, 5],
            'c': [1, 2]
        }
    }

    assert obj_merge({'a': {
        'e': [1, 2],
        'f': [5, 6]
    }}, {
        'a': {
            'e': [3, 4]
        },
        'b': ['1']
    },
                     is_strategic=False) == {
                         'a': {
                             'e': [1, 2],
                             'f': [5, 6]
                         }
                     }
    assert obj_merge({'a': []}, {'a': [1, 2]}, is_strategic=False) == {'a': []}
    assert obj_merge({'a': {
        'b': [1, 2]
    }}, {'a': [1, 2]}, is_strategic=False) == {
        'a': {
            'b': [1, 2]
        }
    }
    assert obj_merge({'a': {
        'b': [1, 2]
    }}, {'a': {
        'b': [],
        'c': [1, 2]
    }},
                     is_strategic=False) == {
                         'a': {
                             'b': [1, 2]
                         }
                     }
    assert obj_merge({'a': {
        'b': [1, 2]
    }}, {'a': {
        'b': [3, 4, 5],
        'c': [1, 2]
    }},
                     is_strategic=False) == {
                         'a': {
                             'b': [1, 2]
                         }
                     }