Merge "Move all volume v2 service client unit tests to v3 dir"
This commit is contained in:
@@ -1,117 +0,0 @@
|
||||
# Copyright 2017 FiberHome Telecommunication Technologies CO.,LTD
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.volume.v2 import backups_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
|
||||
class TestBackupsClient(base.BaseServiceTest):
|
||||
|
||||
FAKE_BACKUP_LIST = {
|
||||
"backups": [
|
||||
{
|
||||
"id": "2ef47aee-8844-490c-804d-2a8efe561c65",
|
||||
"links": [
|
||||
{
|
||||
"href": "fake-url-1",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "fake-url-2",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"name": "backup001"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
FAKE_BACKUP_LIST_WITH_DETAIL = {
|
||||
"backups": [
|
||||
{
|
||||
"availability_zone": "az1",
|
||||
"container": "volumebackups",
|
||||
"created_at": "2013-04-02T10:35:27.000000",
|
||||
"description": None,
|
||||
"fail_reason": None,
|
||||
"id": "2ef47aee-8844-490c-804d-2a8efe561c65",
|
||||
"links": [
|
||||
{
|
||||
"href": "fake-url-1",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "fake-url-2",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"name": "backup001",
|
||||
"object_count": 22,
|
||||
"size": 1,
|
||||
"status": "available",
|
||||
"volume_id": "e5185058-943a-4cb4-96d9-72c184c337d6",
|
||||
"is_incremental": True,
|
||||
"has_dependent_backups": False
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestBackupsClient, self).setUp()
|
||||
fake_auth = fake_auth_provider.FakeAuthProvider()
|
||||
self.client = backups_client.BackupsClient(fake_auth,
|
||||
'volume',
|
||||
'regionOne')
|
||||
|
||||
def _test_list_backups(self, detail=False, mock_args='backups',
|
||||
bytes_body=False, **params):
|
||||
if detail:
|
||||
resp_body = self.FAKE_BACKUP_LIST_WITH_DETAIL
|
||||
else:
|
||||
resp_body = self.FAKE_BACKUP_LIST
|
||||
self.check_service_client_function(
|
||||
self.client.list_backups,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
resp_body,
|
||||
to_utf=bytes_body,
|
||||
mock_args=[mock_args],
|
||||
detail=detail,
|
||||
**params)
|
||||
|
||||
def test_list_backups_with_str_body(self):
|
||||
self._test_list_backups()
|
||||
|
||||
def test_list_backups_with_bytes_body(self):
|
||||
self._test_list_backups(bytes_body=True)
|
||||
|
||||
def test_list_backups_with_detail_with_str_body(self):
|
||||
mock_args = "backups/detail"
|
||||
self._test_list_backups(detail=True, mock_args=mock_args)
|
||||
|
||||
def test_list_backups_with_detail_with_bytes_body(self):
|
||||
mock_args = "backups/detail"
|
||||
self._test_list_backups(detail=True, mock_args=mock_args,
|
||||
bytes_body=True)
|
||||
|
||||
def test_list_backups_with_params(self):
|
||||
# Run the test separately for each param, to avoid assertion error
|
||||
# resulting from randomized params order.
|
||||
mock_args = 'backups?sort_key=name'
|
||||
self._test_list_backups(mock_args=mock_args, sort_key='name')
|
||||
|
||||
mock_args = 'backups/detail?limit=10'
|
||||
self._test_list_backups(detail=True, mock_args=mock_args,
|
||||
bytes_body=True, limit=10)
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.volume.v2 import availability_zone_client
|
||||
from tempest.lib.services.volume.v3 import availability_zone_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
@@ -20,6 +20,55 @@ from tempest.tests.lib.services import base
|
||||
|
||||
class TestBackupsClient(base.BaseServiceTest):
|
||||
|
||||
FAKE_BACKUP_LIST = {
|
||||
"backups": [
|
||||
{
|
||||
"id": "2ef47aee-8844-490c-804d-2a8efe561c65",
|
||||
"links": [
|
||||
{
|
||||
"href": "fake-url-1",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "fake-url-2",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"name": "backup001"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
FAKE_BACKUP_LIST_WITH_DETAIL = {
|
||||
"backups": [
|
||||
{
|
||||
"availability_zone": "az1",
|
||||
"container": "volumebackups",
|
||||
"created_at": "2013-04-02T10:35:27.000000",
|
||||
"description": None,
|
||||
"fail_reason": None,
|
||||
"id": "2ef47aee-8844-490c-804d-2a8efe561c65",
|
||||
"links": [
|
||||
{
|
||||
"href": "fake-url-1",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "fake-url-2",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"name": "backup001",
|
||||
"object_count": 22,
|
||||
"size": 1,
|
||||
"status": "available",
|
||||
"volume_id": "e5185058-943a-4cb4-96d9-72c184c337d6",
|
||||
"is_incremental": True,
|
||||
"has_dependent_backups": False
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
FAKE_BACKUP_UPDATE = {
|
||||
"backup": {
|
||||
"id": "4c65c15f-a5c5-464b-b92a-90e4c04636a7",
|
||||
@@ -35,6 +84,46 @@ class TestBackupsClient(base.BaseServiceTest):
|
||||
'volume',
|
||||
'regionOne')
|
||||
|
||||
def _test_list_backups(self, detail=False, mock_args='backups',
|
||||
bytes_body=False, **params):
|
||||
if detail:
|
||||
resp_body = self.FAKE_BACKUP_LIST_WITH_DETAIL
|
||||
else:
|
||||
resp_body = self.FAKE_BACKUP_LIST
|
||||
self.check_service_client_function(
|
||||
self.client.list_backups,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
resp_body,
|
||||
to_utf=bytes_body,
|
||||
mock_args=[mock_args],
|
||||
detail=detail,
|
||||
**params)
|
||||
|
||||
def test_list_backups_with_str_body(self):
|
||||
self._test_list_backups()
|
||||
|
||||
def test_list_backups_with_bytes_body(self):
|
||||
self._test_list_backups(bytes_body=True)
|
||||
|
||||
def test_list_backups_with_detail_with_str_body(self):
|
||||
mock_args = "backups/detail"
|
||||
self._test_list_backups(detail=True, mock_args=mock_args)
|
||||
|
||||
def test_list_backups_with_detail_with_bytes_body(self):
|
||||
mock_args = "backups/detail"
|
||||
self._test_list_backups(detail=True, mock_args=mock_args,
|
||||
bytes_body=True)
|
||||
|
||||
def test_list_backups_with_params(self):
|
||||
# Run the test separately for each param, to avoid assertion error
|
||||
# resulting from randomized params order.
|
||||
mock_args = 'backups?sort_key=name'
|
||||
self._test_list_backups(mock_args=mock_args, sort_key='name')
|
||||
|
||||
mock_args = 'backups/detail?limit=10'
|
||||
self._test_list_backups(detail=True, mock_args=mock_args,
|
||||
bytes_body=True, limit=10)
|
||||
|
||||
def _test_update_backup(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.update_backup,
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.volume.v2 import capabilities_client
|
||||
from tempest.lib.services.volume.v3 import capabilities_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.volume.v2 import encryption_types_client
|
||||
from tempest.lib.services.volume.v3 import encryption_types_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.volume.v2 import extensions_client
|
||||
from tempest.lib.services.volume.v3 import extensions_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.volume.v2 import hosts_client
|
||||
from tempest.lib.services.volume.v3 import hosts_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.volume.v2 import limits_client
|
||||
from tempest.lib.services.volume.v3 import limits_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
|
||||
import copy
|
||||
|
||||
from tempest.lib.services.volume.v2 import quota_classes_client
|
||||
from tempest.lib.services.volume.v3 import quota_classes_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.volume.v2 import quotas_client
|
||||
from tempest.lib.services.volume.v3 import quotas_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.volume.v2 import scheduler_stats_client
|
||||
from tempest.lib.services.volume.v3 import scheduler_stats_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
+2
-4
@@ -17,9 +17,7 @@ import mock
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
|
||||
from tempest.lib.services.volume.v2 import snapshot_manage_client
|
||||
from tempest.lib.services.volume.v3 import snapshot_manage_client \
|
||||
as snapshot_manage_clientv3
|
||||
from tempest.lib.services.volume.v3 import snapshot_manage_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
@@ -65,7 +63,7 @@ class TestSnapshotManageClient(base.BaseServiceTest):
|
||||
|
||||
# NOTE: Use sort_keys for json.dumps so that the expected and actual
|
||||
# payloads are guaranteed to be identical for mock_args assert check.
|
||||
with mock.patch.object(snapshot_manage_clientv3.json,
|
||||
with mock.patch.object(snapshot_manage_client.json,
|
||||
'dumps') as mock_dumps:
|
||||
mock_dumps.side_effect = lambda d: json_dumps(d, sort_keys=True)
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.volume.v2 import snapshots_client
|
||||
from tempest.lib.services.volume.v3 import snapshots_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
+3
-5
@@ -18,9 +18,7 @@ import copy
|
||||
import mock
|
||||
from oslo_serialization import jsonutils as json
|
||||
|
||||
from tempest.lib.services.volume.v2 import transfers_client
|
||||
from tempest.lib.services.volume.v3 import transfers_client \
|
||||
as transfers_clientv3
|
||||
from tempest.lib.services.volume.v3 import transfers_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
@@ -65,7 +63,7 @@ class TestTransfersClient(base.BaseServiceTest):
|
||||
|
||||
# NOTE: Use sort_keys for json.dumps so that the expected and actual
|
||||
# payloads are guaranteed to be identical for mock_args assert check.
|
||||
with mock.patch.object(transfers_clientv3.json, 'dumps') as mock_dumps:
|
||||
with mock.patch.object(transfers_client.json, 'dumps') as mock_dumps:
|
||||
mock_dumps.side_effect = lambda d: json_dumps(d, sort_keys=True)
|
||||
|
||||
self.check_service_client_function(
|
||||
@@ -86,7 +84,7 @@ class TestTransfersClient(base.BaseServiceTest):
|
||||
|
||||
# NOTE: Use sort_keys for json.dumps so that the expected and actual
|
||||
# payloads are guaranteed to be identical for mock_args assert check.
|
||||
with mock.patch.object(transfers_clientv3.json, 'dumps') as mock_dumps:
|
||||
with mock.patch.object(transfers_client.json, 'dumps') as mock_dumps:
|
||||
mock_dumps.side_effect = lambda d: json_dumps(d, sort_keys=True)
|
||||
|
||||
self.check_service_client_function(
|
||||
+2
-4
@@ -17,9 +17,7 @@ import mock
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
|
||||
from tempest.lib.services.volume.v2 import volume_manage_client
|
||||
from tempest.lib.services.volume.v3 import volume_manage_client \
|
||||
as volume_manage_clientv3
|
||||
from tempest.lib.services.volume.v3 import volume_manage_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
@@ -93,7 +91,7 @@ class TestVolumeManageClient(base.BaseServiceTest):
|
||||
|
||||
# NOTE: Use sort_keys for json.dumps so that the expected and actual
|
||||
# payloads are guaranteed to be identical for mock_args assert check.
|
||||
with mock.patch.object(volume_manage_clientv3.json,
|
||||
with mock.patch.object(volume_manage_client.json,
|
||||
'dumps') as mock_dumps:
|
||||
mock_dumps.side_effect = lambda d: json_dumps(d, sort_keys=True)
|
||||
|
||||
Reference in New Issue
Block a user