示例#1
0
 def test_authentication_sets_auth_token(self):
     with mock.patch('kazoo.client.ApiKeyAuthRequest') as mock_req_class:
         mock_req = mock.Mock()
         mock_req.execute.return_value = {"auth_token": "authorizethis"}
         mock_req_class.return_value = mock_req
         client = Client(api_key="dsfjasbfkasdf")
         client.authenticate()
         mock_req.execute.assert_called_with(client.BASE_URL)
         self.assertEqual(client.auth_token, "authorizethis")
示例#2
0
 def assert_invalid_constructor_args(self, **kwargs):
     with self.assertRaises(RuntimeError):
         client = Client(**kwargs)
示例#3
0
 def test_with_token_creates_api_key_auth_request(self):
     client = Client(api_key="fhasdlkjfblkasd")
     self.assertEqual(type(client.auth_request), ApiKeyAuthRequest)
示例#4
0
 def test_with_username_and_password_creates_user_auth_request(self):
     client = Client(account_name="user", password="******",
                     username="******")
     self.assertEqual(type(client.auth_request),
                      UsernamePasswordAuthRequest)
示例#5
0
 def test_with_valid_username_creds_does_not_raise(self):
     client = Client(account_name="user", password="******",
                     username="******")
示例#6
0
 def test_with_api_key_does_not_raise(self):
     client = Client(api_key="sometoken")
示例#7
0
 def test_without_api_key_or_credentials_or_user_raises(self):
     with self.assertRaises(RuntimeError):
         client = Client()