1313#
1414
1515import copy
16+ import mock
1617
1718from osc_lib import exceptions
1819from osc_lib import utils
@@ -46,6 +47,7 @@ class TestTypeCreate(TestType):
4647 columns = (
4748 'description' ,
4849 'id' ,
50+ 'is_public' ,
4951 'name' ,
5052 )
5153
@@ -56,6 +58,7 @@ def setUp(self):
5658 self .data = (
5759 self .new_volume_type .description ,
5860 self .new_volume_type .id ,
61+ True ,
5962 self .new_volume_type .name ,
6063 )
6164
@@ -357,8 +360,10 @@ def test_type_set_project_access(self):
357360class TestTypeShow (TestType ):
358361
359362 columns = (
363+ 'access_project_ids' ,
360364 'description' ,
361365 'id' ,
366+ 'is_public' ,
362367 'name' ,
363368 'properties' ,
364369 )
@@ -368,8 +373,10 @@ def setUp(self):
368373
369374 self .volume_type = volume_fakes .FakeType .create_one_type ()
370375 self .data = (
376+ None ,
371377 self .volume_type .description ,
372378 self .volume_type .id ,
379+ True ,
373380 self .volume_type .name ,
374381 utils .format_dict (self .volume_type .extra_specs )
375382 )
@@ -394,6 +401,71 @@ def test_type_show(self):
394401 self .assertEqual (self .columns , columns )
395402 self .assertEqual (self .data , data )
396403
404+ def test_type_show_with_access (self ):
405+ arglist = [
406+ self .volume_type .id
407+ ]
408+ verifylist = [
409+ ("volume_type" , self .volume_type .id )
410+ ]
411+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
412+
413+ private_type = volume_fakes .FakeType .create_one_type (
414+ attrs = {'is_public' : False })
415+ type_access_list = volume_fakes .FakeTypeAccess .create_one_type_access ()
416+ with mock .patch .object (self .types_mock , 'get' ,
417+ return_value = private_type ):
418+ with mock .patch .object (self .types_access_mock , 'list' ,
419+ return_value = [type_access_list ]):
420+ columns , data = self .cmd .take_action (parsed_args )
421+ self .types_mock .get .assert_called_once_with (
422+ self .volume_type .id )
423+ self .types_access_mock .list .assert_called_once_with (
424+ private_type .id )
425+
426+ self .assertEqual (self .columns , columns )
427+ private_type_data = (
428+ utils .format_list ([type_access_list .project_id ]),
429+ private_type .description ,
430+ private_type .id ,
431+ private_type .is_public ,
432+ private_type .name ,
433+ utils .format_dict (private_type .extra_specs )
434+ )
435+ self .assertEqual (private_type_data , data )
436+
437+ def test_type_show_with_list_access_exec (self ):
438+ arglist = [
439+ self .volume_type .id
440+ ]
441+ verifylist = [
442+ ("volume_type" , self .volume_type .id )
443+ ]
444+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
445+
446+ private_type = volume_fakes .FakeType .create_one_type (
447+ attrs = {'is_public' : False })
448+ with mock .patch .object (self .types_mock , 'get' ,
449+ return_value = private_type ):
450+ with mock .patch .object (self .types_access_mock , 'list' ,
451+ side_effect = Exception ()):
452+ columns , data = self .cmd .take_action (parsed_args )
453+ self .types_mock .get .assert_called_once_with (
454+ self .volume_type .id )
455+ self .types_access_mock .list .assert_called_once_with (
456+ private_type .id )
457+
458+ self .assertEqual (self .columns , columns )
459+ private_type_data = (
460+ None ,
461+ private_type .description ,
462+ private_type .id ,
463+ private_type .is_public ,
464+ private_type .name ,
465+ utils .format_dict (private_type .extra_specs )
466+ )
467+ self .assertEqual (private_type_data , data )
468+
397469
398470class TestTypeUnset (TestType ):
399471
0 commit comments