def test_get_all_snapshots_not_admin(self): ctx = context.RequestContext("fakeuid", "fakepid", id_admin=False) self.mox.StubOutWithMock(share_api.policy, "check_policy") share_api.policy.check_policy(ctx, "share", "get_all_snapshots") self.mox.StubOutWithMock(db_driver, "share_snapshot_get_all_by_project") db_driver.share_snapshot_get_all_by_project(ctx, "fakepid") self.mox.ReplayAll() self.api.get_all_snapshots(ctx)
def test_get_all_snapshots_not_admin(self): ctx = context.RequestContext('fakeuid', 'fakepid', id_admin=False) self.mox.StubOutWithMock(share_api.policy, 'check_policy') share_api.policy.check_policy(ctx, 'share', 'get_all_snapshots') self.mox.StubOutWithMock(db_driver, 'share_snapshot_get_all_by_project') db_driver.share_snapshot_get_all_by_project(ctx, 'fakepid') self.mox.ReplayAll() self.api.get_all_snapshots(ctx)
def test_get_all_snapshots_not_admin_search_opts(self): search_opts = {"size": "fakesize"} fake_objs = [{"name": "fakename1"}, search_opts] ctx = context.RequestContext("fakeuid", "fakepid", id_admin=False) self.mox.StubOutWithMock(share_api.policy, "check_policy") share_api.policy.check_policy(ctx, "share", "get_all_snapshots") self.mox.StubOutWithMock(db_driver, "share_snapshot_get_all_by_project") db_driver.share_snapshot_get_all_by_project(ctx, "fakepid").AndReturn(fake_objs) self.mox.ReplayAll() result = self.api.get_all_snapshots(ctx, search_opts) self.assertEqual([search_opts], result)
def test_get_all_snapshots_not_admin_search_opts(self): search_opts = {'size': 'fakesize'} fake_objs = [{'name': 'fakename1'}, search_opts] ctx = context.RequestContext('fakeuid', 'fakepid', id_admin=False) self.mox.StubOutWithMock(share_api.policy, 'check_policy') share_api.policy.check_policy(ctx, 'share', 'get_all_snapshots') self.mox.StubOutWithMock(db_driver, 'share_snapshot_get_all_by_project') db_driver.share_snapshot_get_all_by_project(ctx, 'fakepid').\ AndReturn(fake_objs) self.mox.ReplayAll() result = self.api.get_all_snapshots(ctx, search_opts) self.assertEqual([search_opts], result)