예제 #1
0
def test_get_state_clones_body():
    body = {'spec': {'depth': {'field': 'x'}}}
    state = get_state(body=body)
    body['spec']['depth']['field'] = 'y'
    assert state is not body
    assert state['spec'] is not body['spec']
    assert state['spec']['depth'] is not body['spec']['depth']
    assert state['spec']['depth']['field'] == 'x'
예제 #2
0
def test_get_state_removes_kopf_status_and_keeps_others():
    body = {
        'status': {
            'kopf': {
                'progress': 'x',
                'anything': 'y'
            },
            'other': 'z'
        }
    }
    state = get_state(body=body)
    assert state == {'status': {'other': 'z'}}
예제 #3
0
def test_get_state_removes_kopf_status_and_cleans_parents():
    body = {'status': {'kopf': {'progress': 'x', 'anything': 'y'}}}
    state = get_state(body=body)
    assert state == {}
예제 #4
0
def test_get_state_removes_annotations_and_keeps_others(annotation):
    body = {'metadata': {'annotations': {annotation: 'x', 'other': 'y'}}}
    state = get_state(body=body)
    assert state == {'metadata': {'annotations': {'other': 'y'}}}
예제 #5
0
def test_get_state_removes_annotations_and_cleans_parents(annotation):
    body = {'metadata': {'annotations': {annotation: 'x'}}}
    state = get_state(body=body)
    assert state == {}
예제 #6
0
def test_get_state_removes_system_fields_and_keeps_others(field):
    body = {'metadata': {field: 'x', 'other': 'y'}}
    state = get_state(body=body)
    assert state == {'metadata': {'other': 'y'}}
예제 #7
0
def test_get_state_removes_system_fields_and_cleans_parents(field):
    body = {'metadata': {field: 'x'}}
    state = get_state(body=body)
    assert state == {}
예제 #8
0
def test_get_state_removes_status_but_keeps_extra_fields():
    body = {'status': {'kopf': {'progress': 'x', 'anything': 'y'}, 'other': 'z'}}
    state = get_state(body=body, extra_fields=['status.other'])
    assert state == {'status': {'other': 'z'}}
예제 #9
0
def test_get_state_removes_system_fields_but_keeps_extra_fields(field):
    body = {'metadata': {field: 'x', 'other': 'y'}}
    state = get_state(body=body, extra_fields=['metadata.other'])
    assert state == {'metadata': {'other': 'y'}}
예제 #10
0
def test_get_state_removes_resource_references():
    body = {'apiVersion': 'group/version', 'kind': 'Kind'}
    state = get_state(body=body)
    assert state == {}