async def test_supersession_is_logged( registry, settings, resource, handlers, cause_types, cause_mock, caplog, assert_logs): caplog.set_level(logging.DEBUG) settings.persistence.progress_storage = StatusProgressStorage() body = {'status': {'kopf': {'progress': { 'create_fn': {'purpose': cause_types[0]}, 'update_fn': {'purpose': cause_types[0]}, 'resume_fn': {'purpose': cause_types[0]}, 'delete_fn': {'purpose': cause_types[0]}, }}}} cause_mock.reason = cause_types[1] event_type = None if cause_types[1] == Reason.RESUME else 'irrelevant' await process_resource_event( lifecycle=kopf.lifecycles.all_at_once, registry=registry, settings=settings, resource=resource, memories=ResourceMemories(), raw_event={'type': event_type, 'object': body}, replenished=asyncio.Event(), event_queue=asyncio.Queue(), ) assert_logs([ "(Creation|Updating|Resuming|Deletion) is superseded by (creation|updating|resuming|deletion): ", "(Creation|Updating|Resuming|Deletion) is in progress: ", "(Creation|Updating|Resuming|Deletion) is processed: ", ])
def test_status_storage_with_field(): storage = StatusProgressStorage(field='status.my-operator', touch_field='status.my-dummy') assert storage.field == ('status', 'my-operator') assert storage.touch_field == ('status', 'my-dummy')
def test_status_storage_with_name(): storage = StatusProgressStorage(name='my-operator') assert storage.field == ('status', 'my-operator', 'progress') assert storage.touch_field == ('status', 'my-operator', 'dummy')
def test_status_storage_with_defaults(): storage = StatusProgressStorage() assert storage.field == ('status', 'kopf', 'progress' ) # as before the change assert storage.touch_field == ('status', 'kopf', 'dummy' ) # as before the change