Пример #1
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')
Пример #2
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')