예제 #1
0
 def test_reauthentication_on_session_timeout(self):
     """
     If the session_id property is called when the session has actually 
     timed out it should need to reauthenticate and get new a new session_id
     """
     clickatell = Clickatell("username", "password", "api_id", \
                                 client_class=TestClient,
                                 sendmsg_defaults=sendmsg_defaults)
     # manually set it for comparison later
     clickatell.session_id = "old_session_hash"
     self.assertEquals(clickatell.session_id, 'old_session_hash')
     # manually expire by setting the session_start_time beyond the allowed
     # timeout
     clickatell._session_start_time = datetime.now() - \
                                         (Clickatell.SESSION_TIME_OUT * 2)
     # next api.session_id call should call the auth url 
     # because the session's timed out
     clickatell.client.mock('GET', auth_url, {
         'user': '******',
         'password': '******',
         'api_id': 'api_id'
     }, response=clickatell.client.parse_content('OK: new_session_hash'))
     self.assertEquals(clickatell.session_id, 'new_session_hash')
     # make sure the URLs we expected to be called all actually did
     self.assertTrue(clickatell.client.all_mocks_called())
예제 #2
0
 def test_session_timeout(self):
     """
     Check the session time out check by forcing the timeout
     one minute past the allowed limit
     """
     clickatell = Clickatell("username", "password", "api_id", \
                             client_class=TestClient,
                             sendmsg_defaults=sendmsg_defaults)
     delta = Clickatell.SESSION_TIME_OUT
     clickatell._session_start_time = datetime.now() - delta - \
                                             timedelta(minutes=1)
     self.assertTrue(clickatell.session_expired())