def test_catalog_show(self): auth_ref = identity_fakes.fake_auth_ref( identity_fakes.TOKEN_WITH_PROJECT_ID, fake_service=self.fake_service, ) self.ar_mock = mock.PropertyMock(return_value=auth_ref) type(self.app.client_manager).auth_ref = self.ar_mock arglist = [ 'compute', ] verifylist = [ ('service', 'compute'), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # In base command class ShowOne in cliff, abstract method take_action() # returns a two-part tuple with a tuple of column names and a tuple of # data to be shown. columns, data = self.cmd.take_action(parsed_args) collist = ('endpoints', 'id', 'name', 'type') self.assertEqual(collist, columns) datalist = ( 'onlyone\n public: https://public.example.com\nonlyone\n' ' admin: https://admin.example.com\n' '<none>\n internal: https://internal.example.com\n' '<none>\n none: https://none.example.com\n', 'qwertyuiop', 'supernova', 'compute', ) self.assertEqual(datalist, data)
def test_catalog_list(self): auth_ref = identity_fakes.fake_auth_ref( identity_fakes.TOKEN_WITH_PROJECT_ID, fake_service=self.fake_service, ) self.ar_mock = mock.PropertyMock(return_value=auth_ref) type(self.app.client_manager).auth_ref = self.ar_mock arglist = [] verifylist = [] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # In base command class Lister in cliff, abstract method take_action() # returns a tuple containing the column names and an iterable # containing the data to be listed. columns, data = self.cmd.take_action(parsed_args) collist = ('Name', 'Type', 'Endpoints') self.assertEqual(collist, columns) datalist = (( 'supernova', 'compute', 'onlyone\n public: https://public.example.com\n' 'onlyone\n admin: https://admin.example.com\n' '<none>\n internal: https://internal.example.com\n' '<none>\n none: https://none.example.com\n', ), ) self.assertEqual(datalist, tuple(data))
def test_token_issue_with_domain_id(self): auth_ref = identity_fakes.fake_auth_ref( identity_fakes.TOKEN_WITH_DOMAIN_ID, ) self.ar_mock = mock.PropertyMock(return_value=auth_ref) type(self.app.client_manager).auth_ref = self.ar_mock arglist = [] verifylist = [] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # In base command class ShowOne in cliff, abstract method take_action() # returns a two-part tuple with a tuple of column names and a tuple of # data to be shown. columns, data = self.cmd.take_action(parsed_args) collist = ('domain_id', 'expires', 'id', 'user_id') self.assertEqual(collist, columns) datalist = ( identity_fakes.domain_id, identity_fakes.token_expires, identity_fakes.token_id, identity_fakes.user_id, ) self.assertEqual(datalist, data)
def test_token_issue_with_unscoped(self): auth_ref = identity_fakes.fake_auth_ref( identity_fakes.UNSCOPED_TOKEN, ) self.ar_mock = mock.PropertyMock(return_value=auth_ref) type(self.app.client_manager).auth_ref = self.ar_mock arglist = [] verifylist = [] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # DisplayCommandBase.take_action() returns two tuples columns, data = self.cmd.take_action(parsed_args) collist = ( 'expires', 'id', 'user_id', ) self.assertEqual(collist, columns) datalist = ( identity_fakes.token_expires, identity_fakes.token_id, identity_fakes.user_id, ) self.assertEqual(datalist, data)
def test_project_list_my_projects(self): auth_ref = identity_fakes.fake_auth_ref( identity_fakes.TOKEN_WITH_PROJECT_ID, ) ar_mock = mock.PropertyMock(return_value=auth_ref) type(self.app.client_manager).auth_ref = ar_mock arglist = [ '--my-projects', ] verifylist = [ ('my_projects', True), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # In base command class Lister in cliff, abstract method take_action() # returns a tuple containing the column names and an iterable # containing the data to be listed. columns, data = self.cmd.take_action(parsed_args) self.projects_mock.list.assert_called_with( user=self.app.client_manager.auth_ref.user_id) collist = ('ID', 'Name') self.assertEqual(collist, columns) datalist = (( self.project.id, self.project.name, ), ) self.assertEqual(datalist, tuple(data))
def test_token_issue_with_unscoped(self): auth_ref = identity_fakes.fake_auth_ref( identity_fakes.UNSCOPED_TOKEN, ) self.ar_mock = mock.PropertyMock(return_value=auth_ref) type(self.app.client_manager).auth_ref = self.ar_mock arglist = [] verifylist = [] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # DisplayCommandBase.take_action() returns two tuples columns, data = self.cmd.take_action(parsed_args) collist = ( 'expires', 'id', 'user_id', ) self.assertEqual(collist, columns) datalist = ( identity_fakes.token_expires, identity_fakes.token_id, identity_fakes.user_id, ) self.assertEqual(datalist, data)
def test_catalog_list(self): auth_ref = identity_fakes.fake_auth_ref( identity_fakes.TOKEN_WITH_PROJECT_ID, fake_service=self.fake_service, ) self.ar_mock = mock.PropertyMock(return_value=auth_ref) type(self.app.client_manager).auth_ref = self.ar_mock arglist = [] verifylist = [] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # In base command class Lister in cliff, abstract method take_action() # returns a tuple containing the column names and an iterable # containing the data to be listed. columns, data = self.cmd.take_action(parsed_args) collist = ('Name', 'Type', 'Endpoints') self.assertEqual(collist, columns) datalist = (( 'supernova', 'compute', catalog.EndpointsColumn(self.fake_service['endpoints']), ), ) self.assertListItemEqual(datalist, tuple(data))
def test_catalog_list(self): auth_ref = identity_fakes.fake_auth_ref( identity_fakes.TOKEN_WITH_PROJECT_ID, fake_service=self.fake_service, ) self.ar_mock = mock.PropertyMock(return_value=auth_ref) type(self.app.client_manager).auth_ref = self.ar_mock arglist = [] verifylist = [] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # In base command class Lister in cliff, abstract method take_action() # returns a tuple containing the column names and an iterable # containing the data to be listed. columns, data = self.cmd.take_action(parsed_args) collist = ('Name', 'Type', 'Endpoints') self.assertEqual(collist, columns) datalist = (( 'supernova', 'compute', 'onlyone\n public: https://public.example.com\n' 'onlyone\n admin: https://admin.example.com\n' '<none>\n internal: https://internal.example.com\n' '<none>\n none: https://none.example.com\n', ), ) self.assertEqual(datalist, tuple(data))
def test_catalog_show(self): auth_ref = identity_fakes.fake_auth_ref( identity_fakes.TOKEN_WITH_PROJECT_ID, fake_service=self.fake_service, ) self.ar_mock = mock.PropertyMock(return_value=auth_ref) type(self.app.client_manager).auth_ref = self.ar_mock arglist = [ 'compute', ] verifylist = [ ('service', 'compute'), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # In base command class ShowOne in cliff, abstract method take_action() # returns a two-part tuple with a tuple of column names and a tuple of # data to be shown. columns, data = self.cmd.take_action(parsed_args) collist = ('endpoints', 'id', 'name', 'type') self.assertEqual(collist, columns) datalist = ( 'onlyone\n public: https://public.example.com\nonlyone\n' ' admin: https://admin.example.com\n' '<none>\n internal: https://internal.example.com\n' '<none>\n none: https://none.example.com\n', 'qwertyuiop', 'supernova', 'compute', ) self.assertEqual(datalist, data)
def test_catalog_show(self): auth_ref = identity_fakes.fake_auth_ref( identity_fakes.TOKEN_WITH_PROJECT_ID, fake_service=self.fake_service, ) self.ar_mock = mock.PropertyMock(return_value=auth_ref) type(self.app.client_manager).auth_ref = self.ar_mock arglist = [ 'compute', ] verifylist = [ ('service', 'compute'), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # In base command class ShowOne in cliff, abstract method take_action() # returns a two-part tuple with a tuple of column names and a tuple of # data to be shown. columns, data = self.cmd.take_action(parsed_args) collist = ('endpoints', 'id', 'name', 'type') self.assertEqual(collist, columns) datalist = ( catalog.EndpointsColumn( auth_ref.service_catalog.catalog[0]['endpoints']), 'qwertyuiop', 'supernova', 'compute', ) self.assertCountEqual(datalist, data)
def test_token_issue_with_domain_id(self): auth_ref = identity_fakes.fake_auth_ref( identity_fakes.TOKEN_WITH_DOMAIN_ID, ) self.ar_mock = mock.PropertyMock(return_value=auth_ref) type(self.app.client_manager).auth_ref = self.ar_mock arglist = [] verifylist = [] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # In base command class ShowOne in cliff, abstract method take_action() # returns a two-part tuple with a tuple of column names and a tuple of # data to be shown. columns, data = self.cmd.take_action(parsed_args) collist = ('domain_id', 'expires', 'id', 'user_id') self.assertEqual(collist, columns) datalist = ( identity_fakes.domain_id, identity_fakes.token_expires, identity_fakes.token_id, identity_fakes.user_id, ) self.assertEqual(datalist, data)