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)
Esempio n. 2
0
    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_with_both_token_and_endpoint(self,
                                             mocked_get_ksclient,
                                             mocked_get_endpoint):
        kwargs, expected_kwargs = tutils.create_test_dictionary_pair(
            set(self.kwargs.keys()),
            self.redundant_keys,
            self.missing_keys,
            **self.translation_of_args)

        kwargs['os_auth_token'] = 'token'
        kwargs['tuskar_url'] = 'tuskar.api:1234'

        self.assertEqual(client._get_token_and_endpoint(**kwargs),
                         ('token', 'tuskar.api:1234'))
        self.assertEqual(mocked_get_ksclient.call_count, 0)
        self.assertEqual(mocked_get_endpoint.call_count, 0)
Esempio n. 4
0
    def test_it_with_both_token_and_endpoint(self,
                                             mocked_get_ksclient,
                                             mocked_get_endpoint):
        kwargs, expected_kwargs = tutils.create_test_dictionary_pair(
            set(self.kwargs.keys()),
            self.redundant_keys,
            self.missing_keys,
            **self.translation_of_args)

        kwargs['os_auth_token'] = 'token'
        kwargs['tuskar_url'] = 'tuskar.api:1234'

        self.assertEqual(client._get_token_and_endpoint(**kwargs),
                         ('token', 'tuskar.api:1234'))
        self.assertEqual(mocked_get_ksclient.call_count, 0)
        self.assertEqual(mocked_get_endpoint.call_count, 0)
    def test_selects_proper_values(self, mocked_ksclient):
        mocked_ksclient.return_value = 'mocked ksclient'
        keys = set([  # keys for KeystoneClient constructor
            'username',
            'password',
            'tenant_id',
            'tenant_name',
            'auth_url',
            'insecure',
        ])
        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 val. defaults to None
            'username',
            'auth_url',
        ])

        kwargs, ksargs = tutils.create_test_dictionary_pair(keys,
                                                            redundant_keys,
                                                            missing_keys)
        self.assertEqual(client._get_ksclient(**kwargs), 'mocked ksclient')
        mocked_ksclient.assert_called_with(**ksargs)
Esempio n. 6
0
    def test_selects_proper_values(self, mocked_ksclient):
        mocked_ksclient.return_value = 'mocked ksclient'
        keys = set([  # keys for KeystoneClient constructor
            'username',
            'password',
            'tenant_id',
            'tenant_name',
            'auth_url',
            'insecure',
        ])
        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 val. defaults to None
            'username',
            'auth_url',
        ])

        kwargs, ksargs = tutils.create_test_dictionary_pair(keys,
                                                            redundant_keys,
                                                            missing_keys)
        self.assertEqual(client._get_ksclient(**kwargs), 'mocked ksclient')
        mocked_ksclient.assert_called_with(**ksargs)