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'
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'}}
def test_get_state_removes_kopf_status_and_cleans_parents(): body = {'status': {'kopf': {'progress': 'x', 'anything': 'y'}}} state = get_state(body=body) assert state == {}
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'}}}
def test_get_state_removes_annotations_and_cleans_parents(annotation): body = {'metadata': {'annotations': {annotation: 'x'}}} state = get_state(body=body) assert state == {}
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'}}
def test_get_state_removes_system_fields_and_cleans_parents(field): body = {'metadata': {field: 'x'}} state = get_state(body=body) assert state == {}
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'}}
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'}}
def test_get_state_removes_resource_references(): body = {'apiVersion': 'group/version', 'kind': 'Kind'} state = get_state(body=body) assert state == {}