1919from osc_lib import exceptions
2020from osc_lib import utils
2121
22+ from openstackclient .tests .unit .identity .v3 import fakes as project_fakes
2223from openstackclient .tests .unit .volume .v2 import fakes as volume_fakes
2324from openstackclient .volume .v2 import volume_snapshot
2425
@@ -32,6 +33,8 @@ def setUp(self):
3233 self .snapshots_mock .reset_mock ()
3334 self .volumes_mock = self .app .client_manager .volume .volumes
3435 self .volumes_mock .reset_mock ()
36+ self .project_mock = self .app .client_manager .identity .projects
37+ self .project_mock .reset_mock ()
3538
3639
3740class TestSnapshotCreate (TestSnapshot ):
@@ -278,6 +281,7 @@ def test_delete_multiple_snapshots_with_exception(self):
278281class TestSnapshotList (TestSnapshot ):
279282
280283 volume = volume_fakes .FakeVolume .create_one_volume ()
284+ project = project_fakes .FakeProject .create_one_project ()
281285 snapshots = volume_fakes .FakeSnapshot .create_snapshots (
282286 attrs = {'volume_id' : volume .name }, count = 3 )
283287
@@ -321,6 +325,7 @@ def setUp(self):
321325
322326 self .volumes_mock .list .return_value = [self .volume ]
323327 self .volumes_mock .get .return_value = self .volume
328+ self .project_mock .get .return_value = self .project
324329 self .snapshots_mock .list .return_value = self .snapshots
325330 # Get the command to test
326331 self .cmd = volume_snapshot .ListVolumeSnapshot (self .app , None )
@@ -341,6 +346,7 @@ def test_snapshot_list_without_options(self):
341346 'all_tenants' : False ,
342347 'name' : None ,
343348 'status' : None ,
349+ 'project_id' : None ,
344350 'volume_id' : None
345351 }
346352 )
@@ -351,11 +357,13 @@ def test_snapshot_list_with_options(self):
351357 arglist = [
352358 "--long" ,
353359 "--limit" , "2" ,
360+ "--project" , self .project .id ,
354361 "--marker" , self .snapshots [0 ].id ,
355362 ]
356363 verifylist = [
357364 ("long" , True ),
358365 ("limit" , 2 ),
366+ ("project" , self .project .id ),
359367 ("marker" , self .snapshots [0 ].id ),
360368 ('all_projects' , False ),
361369 ]
@@ -367,7 +375,8 @@ def test_snapshot_list_with_options(self):
367375 limit = 2 ,
368376 marker = self .snapshots [0 ].id ,
369377 search_opts = {
370- 'all_tenants' : False ,
378+ 'all_tenants' : True ,
379+ 'project_id' : self .project .id ,
371380 'name' : None ,
372381 'status' : None ,
373382 'volume_id' : None
@@ -394,6 +403,7 @@ def test_snapshot_list_all_projects(self):
394403 'all_tenants' : True ,
395404 'name' : None ,
396405 'status' : None ,
406+ 'project_id' : None ,
397407 'volume_id' : None
398408 }
399409 )
@@ -419,6 +429,7 @@ def test_snapshot_list_name_option(self):
419429 'all_tenants' : False ,
420430 'name' : self .snapshots [0 ].name ,
421431 'status' : None ,
432+ 'project_id' : None ,
422433 'volume_id' : None
423434 }
424435 )
@@ -444,6 +455,7 @@ def test_snapshot_list_status_option(self):
444455 'all_tenants' : False ,
445456 'name' : None ,
446457 'status' : self .snapshots [0 ].status ,
458+ 'project_id' : None ,
447459 'volume_id' : None
448460 }
449461 )
@@ -469,6 +481,7 @@ def test_snapshot_list_volumeid_option(self):
469481 'all_tenants' : False ,
470482 'name' : None ,
471483 'status' : None ,
484+ 'project_id' : None ,
472485 'volume_id' : self .volume .id
473486 }
474487 )
0 commit comments