예제 #1
0
 def test_getbalance(self):
     clickatell = Clickatell('username', 'password', 'api_id', 
                                 client_class=TestClient)
     clickatell.session_id = "session_id"
     self.assertFalse(clickatell.session_expired())
     clickatell.client.mock('GET', getbalance_url, {
         'session_id': 'session_id'
     }, response=clickatell.client.parse_content('Credit: 500.00'))
     self.assertEquals(clickatell.getbalance(), 500.00)
예제 #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())
예제 #3
0
 def test_sendmsg_recipient_validation(self):
     clickatell = Clickatell('username','password','api_id', 
                                 client_class=TestClient,
                                 sendmsg_defaults=sendmsg_defaults)
     clickatell.session_id = "session_id"
     self.assertFalse(clickatell.session_expired())
     for recipient in ['+27123456781', '0027123456781']:
         kwargs = {
             'sender': '27123456781',
             'recipients': [recipient],
             'text': 'hello world'
         }
         self.assertRaises(ClickatellError, clickatell.sendmsg, **kwargs)