def test_it_filters_kwargs(self, mocked_client): mocked_client.return_value = 'mocked client' api_version = 1 endpoint = 'http://tuskar.api:1234' token = 'token' keys = set([ # keys for Client constructor 'insecure', 'timeout', 'ca_file', 'cert_file', 'key_file', ]) redundant_keys = set([ # key added to see if not passed to constructor 'some_other_key', 'any_other_key', ]) missing_keys = set([ # missing to see if its value defaults to None 'ca_file', 'cert_file', ]) kwargs, client_args = tutils.create_test_dictionary_pair( keys, redundant_keys, missing_keys) self.assertEqual(client._get_client_with_token(api_version, os_auth_token=token, tuskar_url=endpoint, **kwargs), 'mocked client') mocked_client.assert_called_with(api_version, endpoint, token=token, **client_args)
def test_it_returns_none_without_endpoint(self): api_version = 1 token = 'token' self.assertEqual( client._get_client_with_token(api_version, os_auth_token=token), None)
def test_it_returns_none_without_token(self): api_version = 1 endpoint = 'http://tuskar.api:1234' self.assertEqual( client._get_client_with_token(api_version, tuskar_url=endpoint), None)