def test_keep_alive_error(self):
     mock_context = mock.Mock()
     mock_flumine = mock.Mock()
     mock_flumine.client.betting_client.session_token = None
     mock_flumine.client.betting_client.keep_alive.side_effect = BetfairError
     worker.keep_alive(mock_context, mock_flumine)
     mock_flumine.client.login.assert_called_with()
 def test_keep_alive_failure(self):
     mock_context = mock.Mock()
     mock_flumine = mock.Mock()
     mock_flumine.client.betting_client.session_token = None
     mock_response = mock.Mock()
     mock_response.status = "FAILURE"
     mock_flumine.client.betting_client.keep_alive.return_value = mock_response
     worker.keep_alive(mock_context, mock_flumine)
     mock_flumine.client.login.assert_called_with()
    def test_keep_alive(self):
        mock_context = mock.Mock()
        mock_flumine = mock.Mock()
        mock_flumine.client.betting_client.session_token = None
        worker.keep_alive(mock_context, mock_flumine)
        mock_flumine.client.login.assert_called_with()

        mock_flumine.client.betting_client.session_token = 1
        mock_flumine.client.betting_client.session_expired = True
        worker.keep_alive(mock_context, mock_flumine)
        mock_flumine.client.keep_alive.assert_called_with()
Exemple #4
0
    def test_keep_alive(self):
        mock_context = mock.Mock()
        mock_client_simulated = mock.Mock(EXCHANGE=ExchangeType.SIMULATED)
        mock_client_betfair = mock.Mock(EXCHANGE=ExchangeType.BETFAIR)
        mock_client_betfair.betting_client.session_token = None
        mock_client_betfair_st = mock.Mock(EXCHANGE=ExchangeType.BETFAIR)
        mock_client_betfair_st.betting_client.session_token = "test"
        mock_client_betconnect = mock.Mock(EXCHANGE=ExchangeType.BETCONNECT)
        mock_client_betconnect.keep_alive.return_value = None
        mock_flumine = mock.Mock(clients=[
            mock_client_simulated,
            mock_client_betfair,
            mock_client_betfair_st,
            mock_client_betconnect,
        ])
        worker.keep_alive(mock_context, mock_flumine)

        mock_client_simulated.login.assert_called_with()
        mock_client_betfair.login.assert_called_with()
        mock_client_betfair_st.keep_alive.assert_called_with()
        mock_client_betfair_st.login.assert_called_with()
        mock_client_betconnect.keep_alive.assert_called_with()
        mock_client_betconnect.login.assert_called_with()