Exemplo n.º 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'
Exemplo n.º 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'}}
Exemplo n.º 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 == {}
Exemplo n.º 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'}}}
Exemplo n.º 5
0
def test_get_state_removes_annotations_and_cleans_parents(annotation):
    body = {'metadata': {'annotations': {annotation: 'x'}}}
    state = get_state(body=body)
    assert state == {}
Exemplo n.º 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'}}
Exemplo n.º 7
0
def test_get_state_removes_system_fields_and_cleans_parents(field):
    body = {'metadata': {field: 'x'}}
    state = get_state(body=body)
    assert state == {}
Exemplo n.º 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'}}
Exemplo n.º 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'}}
Exemplo n.º 10
0
def test_get_state_removes_resource_references():
    body = {'apiVersion': 'group/version', 'kind': 'Kind'}
    state = get_state(body=body)
    assert state == {}