def test_volume_snapshot_get_metadata(self, cc):
     request = self.mock_rest_request(**{'GET': {}})
     cc.volume_snapshot_get.return_value = mock.Mock(
         **{'to_dict.return_value': {'id': 'one',
                                     'metadata': {'foo': 'bar'}}})
     response = cinder.VolumeSnapshotMetadata().get(request, '1')
     self.assertStatusCode(response, 200)
     self.assertEqual(response.json, {'foo': 'bar'})
     cc.volume_snapshot_get.assert_called_once_with(request, '1')
Ejemplo n.º 2
0
    def test_volume_snapshot_get_metadata(self):
        request = self.mock_rest_request(**{'GET': {}})
        # 4th item contains metadata
        snapshot = self.cinder_volume_snapshots.list()[3]
        # Ensure metadata is contained in test data
        assert 'metadata' in snapshot.to_dict()
        self.mock_volume_snapshot_get.return_value = snapshot

        response = cinder.VolumeSnapshotMetadata().get(request, '1')

        self.assertStatusCode(response, 200)
        self.assertEqual(snapshot.metadata, response.json)
        self.mock_volume_snapshot_get.assert_called_once_with(request, '1')
Ejemplo n.º 3
0
 def test_volume_snapshot_update_metadata(self, cc):
     request = self.mock_rest_request(
         body='{"updated": {"a": "1", "b": "2"}, '
         '"removed": ["c", "d"]}')
     response = cinder.VolumeSnapshotMetadata().patch(request, '1')
     self.assertStatusCode(response, 204)
     self.assertEqual(b'', response.content)
     cc.volume_snapshot_set_metadata.assert_called_once_with(
         request, '1', {
             'a': '1',
             'b': '2'
         })
     cc.volume_snapshot_delete_metadata.assert_called_once_with(
         request, '1', ['c', 'd'])