def test_client_new_with_kwargs_token(self, mock_ks_loader, mock_ks_session): session = mock_ks_session.return_value.load_from_options.return_value mock_ks_loader.return_value.load_from_options.return_value = 'auth' kwargs = { 'auth_url': 'one', 'project_id': 'two', 'project_name': 'four', 'user_domain_id': 'five', 'user_domain_name': 'six', 'project_domain_id': 'senven', 'project_domain_name': 'eight', 'token': 'nine' } c = client.Client(**kwargs) self.assertIsInstance(c, client.Client) self.assertEqual('one', c.opts.os_auth_url) self.assertEqual('two', c.opts.os_project_id) self.assertEqual('four', c.opts.os_project_name) self.assertEqual('five', c.opts.os_user_domain_id) self.assertEqual('six', c.opts.os_user_domain_name) self.assertEqual('senven', c.opts.os_project_domain_id) self.assertEqual('eight', c.opts.os_project_domain_name) self.assertEqual('nine', c.opts.os_token) self.assertEqual(session, c.session)
def test_get_token(self, mock_ks_loader, mock_ks_session): mock_ks_loader.return_value.load_from_options.return_value = 'auth' mock_session = mock.Mock() mock_session.get_token.return_value = 'antaniX2' c = client.Client(session=mock_session, endpoint='justtest', auth_url='blabla') self.assertIsInstance(c, client.Client) self.assertEqual(c.auth_token, 'antaniX2')
def test_get_client_id(self, mock_ks_loader, mock_ks_session, mock_socket): mock_ks_loader.return_value.load_from_options.return_value = 'auth' mock_socket.gethostname.return_value = 'parmenide' mock_session = mock.Mock() mock_session.get_project_id.return_value = 'H2O' c = client.Client(session=mock_session, endpoint='justtest', auth_url='blabla') self.assertIsInstance(c, client.Client) self.assertEqual(c.client_id, 'H2O_parmenide')
def test_client_new_with_kwargs_session(self, mock_ks_loader, mock_ks_session): mock_ks_loader.return_value.load_from_options.return_value = 'auth' mock_session = mock.Mock() kwargs = { 'token': 'alpha', 'username': '******', 'password': '******', 'project_name': 'delta', 'auth_url': 'echo', 'endpoint': 'golf', 'session': mock_session } c = client.Client(**kwargs) self.assertIsInstance(c, client.Client) self.assertEqual('alpha', c.opts.os_token) self.assertEqual('bravo', c.opts.os_username) self.assertEqual('charlie', c.opts.os_password) self.assertEqual('delta', c.opts.os_project_name) self.assertEqual('echo', c.opts.os_auth_url) self.assertEqual(mock_session, c._session) self.assertEqual(mock_session, c.session) self.assertEqual('golf', c.endpoint)
def test_client_new(self, mock_ks_loader, mock_ks_session): session = mock_ks_session.return_value.load_from_options.return_value mock_ks_loader.return_value.load_from_options.return_value = 'auth' c = client.Client(endpoint='blabla', auth_url='blabla') self.assertIsInstance(c, client.Client) self.assertEqual(session, c.session)