Пример #1
0
def test_get_essence_clones_body():
    body = {'spec': {'depth': {'field': 'x'}}}
    essence = get_essence(body=body)
    body['spec']['depth']['field'] = 'y'
    assert essence is not body
    assert essence['spec'] is not body['spec']
    assert essence['spec']['depth'] is not body['spec']['depth']
    assert essence['spec']['depth']['field'] == 'x'
Пример #2
0
def test_get_essence_removes_status_and_cleans_parents():
    body = {
        'status': {
            'kopf': {
                'progress': 'x',
                'anything': 'y'
            },
            'other': 'z'
        }
    }
    essence = get_essence(body=body)
    assert essence == {}
Пример #3
0
def test_get_essence_removes_status_but_keeps_extra_fields():
    body = {
        'status': {
            'kopf': {
                'progress': 'x',
                'anything': 'y'
            },
            'other': 'z'
        }
    }
    essence = get_essence(body=body, extra_fields=['status.other'])
    assert essence == {'status': {'other': 'z'}}
Пример #4
0
def test_get_essence_removes_garbage_annotations_but_keeps_others(annotation):
    body = {'metadata': {'annotations': {annotation: 'x', 'other': 'y'}}}
    essence = get_essence(body=body)
    assert essence == {'metadata': {'annotations': {'other': 'y'}}}
Пример #5
0
def test_get_essence_removes_garbage_annotations_and_cleans_parents(
        annotation):
    body = {'metadata': {'annotations': {annotation: 'x'}}}
    essence = get_essence(body=body)
    assert essence == {}
Пример #6
0
def test_get_essence_removes_system_fields_but_keeps_extra_fields(field):
    body = {'metadata': {field: 'x', 'other': 'y'}}
    essence = get_essence(body=body, extra_fields=['metadata.other'])
    assert essence == {'metadata': {'other': 'y'}}
Пример #7
0
def test_get_essence_removes_system_fields_and_cleans_parents(field):
    body = {'metadata': {field: 'x'}}
    essence = get_essence(body=body)
    assert essence == {}
Пример #8
0
def test_get_essence_removes_resource_references():
    body = {'apiVersion': 'group/version', 'kind': 'Kind'}
    essence = get_essence(body=body)
    assert essence == {}