def next_action(frozen, state): if state in ('submitted', 'unknown'): return 'reconcile' if state in ('confirmed', 'rejected'): return 'archive' if state == 'queued': return 'hold' if frozen else 'review' return 'hold' if __name__ == '__main__': assert next_action(True, 'queued') == 'hold' assert next_action(True, 'unknown') == 'reconcile' assert next_action(False, 'submitted') == 'reconcile' assert next_action(False, 'unexpected') == 'hold'