def test_volume_snaps_get(self, cc):
     request = self.mock_rest_request(**{'GET': {}})
     cc.volume_snapshot_list.return_value = [
         mock.Mock(**{'to_dict.return_value': {'id': 'one'}}),
         mock.Mock(**{'to_dict.return_value': {'id': 'two'}}),
     ]
     response = cinder.VolumeSnapshots().get(request)
     self.assertStatusCode(response, 200)
     self.assertEqual(response.json,
                      {"items": [{"id": "one"}, {"id": "two"}]})
     cc.volume_snapshot_list.assert_called_once_with(request,
                                                     search_opts={})
    def test_volume_snaps_get(self):
        request = self.mock_rest_request(**{'GET': {}})
        snapshots = self.cinder_volume_snapshots.list()
        self.mock_volume_snapshot_list.return_value = snapshots

        response = cinder.VolumeSnapshots().get(request)

        self.assertStatusCode(response, 200)
        self.assertEqual([s.to_dict() for s in snapshots],
                         response.json['items'])
        self.mock_volume_snapshot_list.assert_called_once_with(request,
                                                               search_opts={})
Exemple #3
0
 def test_volume_snaps_get_with_filters(self, cc):
     filters = {'status': 'available'}
     request = self.mock_rest_request(**{'GET': dict(filters)})
     cc.volume_snapshot_list.return_value = [
         mock.Mock(**{'to_dict.return_value': {
             'id': 'one'
         }}),
         mock.Mock(**{'to_dict.return_value': {
             'id': 'two'
         }}),
     ]
     response = cinder.VolumeSnapshots().get(request)
     self.assertStatusCode(response, 200)
     self.assertEqual(response.content,
                      '{"items": [{"id": "one"}, {"id": "two"}]}')
     cc.volume_snapshot_list.assert_called_once_with(request,
                                                     search_opts=filters)