예제 #1
0
 def test_post(self):
     client = TestClient()
     mocked_response = {'OK': '123456789'}
     data = {'keyword': 'argument'}
     client.mock('POST', 'http://api.clickatell.com', \
                             data=data, response=mocked_response)
     self.assertEquals(mocked_response, \
                         client.post('http://api.clickatell.com', \
                                             data=data))
예제 #2
0
 def test_get(self):
     client = TestClient()
     mocked_response = {'OK': '123456789'}
     data = {'q': "Testing Client Lib"}
     client.mock('GET', 'http://api.clickatell.com', \
                             data = data, response = mocked_response)
     self.assertEquals(mocked_response, \
                         client.get('http://api.clickatell.com', \
                                             data=data))
예제 #3
0
 def test_ok_authentication(self):
     "test OK / success response"
     client = TestClient()
     client.mock('get', auth_url, {
         'user': '******',
         'password': '******',
         'api_id': '123456'
     }, response=client.parse_content("OK: somerandomhash"))
     [ok] = client.http('auth', {
         'user': '******', 
         'password': '******', 
         'api_id': '123456'
     })
     self.assertTrue(isinstance(ok, OKResponse))
     self.assertEquals(ok.value, 'somerandomhash')
예제 #4
0
 def test_err_authentication(self):
     "test ERR / fail response"
     client = TestClient()
     client.mock('get', auth_url, {
         'user': '******',
         'password': '******',
         'api_id': '123456'
     }, response=client.parse_content('ERR: 001, Authentication Failed'))
     [err] = client.http('auth', {
         'user': '******', 
         'password': '******', 
         'api_id': '123456'
     })
     self.assertTrue(isinstance(err, ERRResponse))
     self.assertEquals(err.code, 1)
     self.assertEquals(err.reason, 'Authentication Failed')