Ejemplo n.º 1
0
    async def test_close(self, mock_interaction_server: interaction_server_impl.InteractionServer):
        mock_runner = mock.AsyncMock()
        mock_event = mock.Mock()
        mock_interaction_server._is_closing = False
        mock_interaction_server._server = mock_runner
        mock_interaction_server._close_event = mock_event

        await mock_interaction_server.close()

        mock_runner.shutdown.assert_awaited_once()
        mock_runner.cleanup.assert_awaited_once()
        mock_event.set.assert_called_once()
        assert mock_interaction_server._is_closing is True
Ejemplo n.º 2
0
    async def test_close_when_closing(self, mock_interaction_server: interaction_server_impl.InteractionServer):
        mock_runner = mock.AsyncMock()
        mock_event = mock.Mock()
        mock_interaction_server._server = mock_runner
        mock_interaction_server._close_event = mock_event
        mock_interaction_server._is_closing = True
        mock_interaction_server.join = mock.AsyncMock()

        await mock_interaction_server.close()

        mock_runner.shutdown.assert_not_called()
        mock_runner.cleanup.assert_not_called()
        mock_event.set.assert_not_called()
        mock_interaction_server.join.assert_awaited_once()