# Path: repokid/dispatcher/types.py
# class Message(BaseModel):
#     account: str
#     command: str
#     role_name: str
#     respond_channel: str
#     errors: List[str] = Field(default=[])
#     respond_user: str = Field(default="")
#     requestor: str = Field(default="")
#     reason: str = Field(default="")
#     selection: str = Field(default="")


import copy
import pytest
import repokid.dispatcher as dispatcher
from mock import call
from mock import patch
from pydantic.error_wrappers import ValidationError
from repokid.dispatcher.types import Message
        mock_find_role_in_cache,
        mock_role_fetch,
        mock_get_services_and_permissions_from_repoable,
    ):
        mock_find_role_in_cache.side_effect = [None, "ROLE_ID_A"]
        mock_get_services_and_permissions_from_repoable.return_value = {"foo", "bar"}

        success, _ = dispatcher.list_repoable_services(MESSAGE)
        assert not success
        mock_find_role_in_cache.assert_called_once()
        mock_role_fetch.assert_not_called()
        mock_get_services_and_permissions_from_repoable.assert_not_called()

        mock_role_fetch.reset_mock()
        mock_get_services_and_permissions_from_repoable.reset_mock()
        mock_find_role_in_cache.reset_mock()

        success, _ = dispatcher.list_repoable_services(MESSAGE)
        assert success
        mock_find_role_in_cache.assert_called_once()
        mock_role_fetch.assert_called_once()
        mock_get_services_and_permissions_from_repoable.assert_called_once()

    @patch("repokid.role.Role.fetch")
    @patch("repokid.dispatcher.find_role_in_cache")
    def test_list_role_rollbacks(self, mock_find_role_in_cache, mock_role_fetch):
        mock_find_role_in_cache.side_effect = [None, "ROLE_ID_A"]

        (success, _) = dispatcher.list_role_rollbacks(MESSAGE)
        assert not success

# Path: repokid/dispatcher/types.py
# class Message(BaseModel):
#     account: str
#     command: str
#     role_name: str
#     respond_channel: str
#     errors: List[str] = Field(default=[])
#     respond_user: str = Field(default="")
#     requestor: str = Field(default="")
#     reason: str = Field(default="")
#     selection: str = Field(default="")


# Path: tests/test_dispatcher_cli.py
import copy
import pytest
import repokid.dispatcher as dispatcher
from mock import call
from mock import patch
from pydantic.error_wrappers import ValidationError
from repokid.dispatcher.types import Message

        mock_find_role_in_cache,
        mock_role_fetch,
        mock_get_services_and_permissions_from_repoable,
    ):
        mock_find_role_in_cache.side_effect = [None, "ROLE_ID_A"]
        mock_get_services_and_permissions_from_repoable.return_value = {"foo", "bar"}

        success, _ = dispatcher.list_repoable_services(MESSAGE)
        assert not success
        mock_find_role_in_cache.assert_called_once()
        mock_role_fetch.assert_not_called()
        mock_get_services_and_permissions_from_repoable.assert_not_called()

        mock_role_fetch.reset_mock()
        mock_get_services_and_permissions_from_repoable.reset_mock()
        mock_find_role_in_cache.reset_mock()

        success, _ = dispatcher.list_repoable_services(MESSAGE)
        assert success
        mock_find_role_in_cache.assert_called_once()
        mock_role_fetch.assert_called_once()
        mock_get_services_and_permissions_from_repoable.assert_called_once()

    @patch("repokid.role.Role.fetch")
    @patch("repokid.dispatcher.find_role_in_cache")
    def test_list_role_rollbacks(self, mock_find_role_in_cache, mock_role_fetch):
        mock_find_role_in_cache.side_effect = [None, "ROLE_ID_A"]

        (success, _) = dispatcher.list_role_rollbacks(MESSAGE)
        assert not success

        mock_find_role_in_cache.assert_called_once()