# Path: clearly/server/expected_state.py
# def setup_task_states() -> ExpectedStateHandler:
#     terminal = (SUCCESS, FAILURE, REJECTED, REVOKED)
# 
#     pending = ExpectedPath(PENDING)
#     received = pending.to(RECEIVED)
#     received.to(STARTED) \
#         .to(terminal, RETRY) \
#         .to(pending, received)
# 
#     return ExpectedStateHandler(pending)


import pytest
from celery.states import FAILURE, PENDING, RECEIVED, REJECTED, RETRY, REVOKED, STARTED, SUCCESS
from clearly.server.expected_state import setup_task_states
    (REJECTED, STARTED, UserWarning),
    (REJECTED, SUCCESS, UserWarning),
    (REJECTED, FAILURE, UserWarning),
    (REJECTED, REJECTED, []),
    (REJECTED, REVOKED, UserWarning),
    (REJECTED, RETRY, UserWarning),
    (REVOKED, PENDING, UserWarning),
    (REVOKED, RECEIVED, UserWarning),
    (REVOKED, STARTED, UserWarning),
    (REVOKED, SUCCESS, UserWarning),
    (REVOKED, FAILURE, UserWarning),
    (REVOKED, REJECTED, UserWarning),
    (REVOKED, REVOKED, []),
    (REVOKED, RETRY, UserWarning),
    (RETRY, PENDING, [PENDING]),
    (RETRY, RECEIVED, [RECEIVED]),
    (RETRY, STARTED, [RECEIVED, STARTED]),
    (RETRY, SUCCESS, [RECEIVED, STARTED, SUCCESS]),
    (RETRY, FAILURE, [RECEIVED, STARTED, FAILURE]),
    (RETRY, REJECTED, [RECEIVED, STARTED, REJECTED]),
    (RETRY, REVOKED, [RECEIVED, STARTED, REVOKED]),
    (RETRY, RETRY, []),
])
def test_expected_states_task(state_initial, state, expected):
    states = setup_task_states()

    if isinstance(expected, list):
        assert list(states.states_through(state_initial, state)) == expected
    else:
        with pytest.raises(expected):

# Path: clearly/server/expected_state.py
# def setup_task_states() -> ExpectedStateHandler:
#     terminal = (SUCCESS, FAILURE, REJECTED, REVOKED)
# 
#     pending = ExpectedPath(PENDING)
#     received = pending.to(RECEIVED)
#     received.to(STARTED) \
#         .to(terminal, RETRY) \
#         .to(pending, received)
# 
#     return ExpectedStateHandler(pending)


# Path: tests/unit/server/test_expected_state.py
import pytest
from celery.states import FAILURE, PENDING, RECEIVED, REJECTED, RETRY, REVOKED, STARTED, SUCCESS
from clearly.server.expected_state import setup_task_states

    (REJECTED, STARTED, UserWarning),
    (REJECTED, SUCCESS, UserWarning),
    (REJECTED, FAILURE, UserWarning),
    (REJECTED, REJECTED, []),
    (REJECTED, REVOKED, UserWarning),
    (REJECTED, RETRY, UserWarning),
    (REVOKED, PENDING, UserWarning),
    (REVOKED, RECEIVED, UserWarning),
    (REVOKED, STARTED, UserWarning),
    (REVOKED, SUCCESS, UserWarning),
    (REVOKED, FAILURE, UserWarning),
    (REVOKED, REJECTED, UserWarning),
    (REVOKED, REVOKED, []),
    (REVOKED, RETRY, UserWarning),
    (RETRY, PENDING, [PENDING]),
    (RETRY, RECEIVED, [RECEIVED]),
    (RETRY, STARTED, [RECEIVED, STARTED]),
    (RETRY, SUCCESS, [RECEIVED, STARTED, SUCCESS]),
    (RETRY, FAILURE, [RECEIVED, STARTED, FAILURE]),
    (RETRY, REJECTED, [RECEIVED, STARTED, REJECTED]),
    (RETRY, REVOKED, [RECEIVED, STARTED, REVOKED]),
    (RETRY, RETRY, []),
])
def test_expected_states_task(state_initial, state, expected):
    states = setup_task_states()

    if isinstance(expected, list):
        assert list(states.states_through(state_initial, state)) == expected
    else:
        with pytest.raises(expected):

            list(states.states_through(state_initial, state))