Merge "Fix confusing variable names in unit tests"
This commit is contained in:
commit
2933ca2ce9
@ -80,37 +80,37 @@ class VolumeSnapshotsViewTests(test.BaseAdminViewTests):
|
||||
@override_settings(API_RESULT_PAGE_SIZE=1)
|
||||
def test_snapshots_index_paginated(self):
|
||||
size = settings.API_RESULT_PAGE_SIZE
|
||||
mox_snapshots = self.cinder_volume_snapshots.list()
|
||||
snapshots = self.cinder_volume_snapshots.list()
|
||||
base_url = reverse(INDEX_URL)
|
||||
next = tables.VolumeSnapshotsTable._meta.pagination_param
|
||||
|
||||
# get first page
|
||||
expected_snapshots = mox_snapshots[:size]
|
||||
expected_snapshots = snapshots[:size]
|
||||
res = self._test_snapshots_index_paginated(
|
||||
marker=None, sort_dir="desc", snapshots=expected_snapshots,
|
||||
url=base_url, has_more=True, has_prev=False)
|
||||
snapshots = res.context['volume_snapshots_table'].data
|
||||
self.assertItemsEqual(snapshots, expected_snapshots)
|
||||
result = res.context['volume_snapshots_table'].data
|
||||
self.assertItemsEqual(result, expected_snapshots)
|
||||
|
||||
# get second page
|
||||
expected_snapshots = mox_snapshots[size:2 * size]
|
||||
expected_snapshots = snapshots[size:2 * size]
|
||||
marker = expected_snapshots[0].id
|
||||
url = base_url + "?%s=%s" % (next, marker)
|
||||
res = self._test_snapshots_index_paginated(
|
||||
marker=marker, sort_dir="desc", snapshots=expected_snapshots,
|
||||
url=url, has_more=True, has_prev=True)
|
||||
snapshots = res.context['volume_snapshots_table'].data
|
||||
self.assertItemsEqual(snapshots, expected_snapshots)
|
||||
result = res.context['volume_snapshots_table'].data
|
||||
self.assertItemsEqual(result, expected_snapshots)
|
||||
|
||||
# get last page
|
||||
expected_snapshots = mox_snapshots[-size:]
|
||||
expected_snapshots = snapshots[-size:]
|
||||
marker = expected_snapshots[0].id
|
||||
url = base_url + "?%s=%s" % (next, marker)
|
||||
res = self._test_snapshots_index_paginated(
|
||||
marker=marker, sort_dir="desc", snapshots=expected_snapshots,
|
||||
url=url, has_more=False, has_prev=True)
|
||||
snapshots = res.context['volume_snapshots_table'].data
|
||||
self.assertItemsEqual(snapshots, expected_snapshots)
|
||||
result = res.context['volume_snapshots_table'].data
|
||||
self.assertItemsEqual(result, expected_snapshots)
|
||||
|
||||
@override_settings(API_RESULT_PAGE_SIZE=1)
|
||||
def test_snapshots_index_paginated_prev(self):
|
||||
|
@ -131,62 +131,62 @@ class VolumeTests(test.BaseAdminViewTests):
|
||||
@override_settings(API_RESULT_PAGE_SIZE=2)
|
||||
def test_index_paginated(self):
|
||||
size = settings.API_RESULT_PAGE_SIZE
|
||||
mox_volumes = self._ensure_attachments_exist(
|
||||
volumes = self._ensure_attachments_exist(
|
||||
self.cinder_volumes.list())
|
||||
|
||||
# get first page
|
||||
expected_volumes = mox_volumes[:size]
|
||||
expected_volumes = volumes[:size]
|
||||
url = INDEX_URL
|
||||
res = self._test_index_paginated(None, "desc", expected_volumes, url,
|
||||
True, False)
|
||||
volumes = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(volumes, expected_volumes)
|
||||
result = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(result, expected_volumes)
|
||||
|
||||
# get second page
|
||||
expected_volumes = mox_volumes[size:2 * size]
|
||||
expected_volumes = volumes[size:2 * size]
|
||||
marker = expected_volumes[0].id
|
||||
next = volume_tables.VolumesTable._meta.pagination_param
|
||||
url = INDEX_URL + "?%s=%s" % (next, marker)
|
||||
res = self._test_index_paginated(marker, "desc", expected_volumes, url,
|
||||
True, True)
|
||||
volumes = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(volumes, expected_volumes)
|
||||
result = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(result, expected_volumes)
|
||||
|
||||
# get last page
|
||||
expected_volumes = mox_volumes[-size:]
|
||||
expected_volumes = volumes[-size:]
|
||||
marker = expected_volumes[0].id
|
||||
next = volume_tables.VolumesTable._meta.pagination_param
|
||||
url = INDEX_URL + "?%s=%s" % (next, marker)
|
||||
res = self._test_index_paginated(marker, "desc", expected_volumes, url,
|
||||
False, True)
|
||||
volumes = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(volumes, expected_volumes)
|
||||
result = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(result, expected_volumes)
|
||||
|
||||
@override_settings(API_RESULT_PAGE_SIZE=2)
|
||||
def test_index_paginated_prev(self):
|
||||
size = settings.API_RESULT_PAGE_SIZE
|
||||
mox_volumes = self._ensure_attachments_exist(
|
||||
volumes = self._ensure_attachments_exist(
|
||||
self.cinder_volumes.list())
|
||||
|
||||
# prev from some page
|
||||
expected_volumes = mox_volumes[size:2 * size]
|
||||
marker = mox_volumes[0].id
|
||||
expected_volumes = volumes[size:2 * size]
|
||||
marker = volumes[0].id
|
||||
prev = volume_tables.VolumesTable._meta.prev_pagination_param
|
||||
url = INDEX_URL + "?%s=%s" % (prev, marker)
|
||||
res = self._test_index_paginated(marker, "asc", expected_volumes, url,
|
||||
False, True)
|
||||
volumes = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(volumes, expected_volumes)
|
||||
result = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(result, expected_volumes)
|
||||
|
||||
# back to first page
|
||||
expected_volumes = mox_volumes[:size]
|
||||
marker = mox_volumes[0].id
|
||||
expected_volumes = volumes[:size]
|
||||
marker = volumes[0].id
|
||||
prev = volume_tables.VolumesTable._meta.prev_pagination_param
|
||||
url = INDEX_URL + "?%s=%s" % (prev, marker)
|
||||
res = self._test_index_paginated(marker, "asc", expected_volumes, url,
|
||||
True, False)
|
||||
volumes = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(volumes, expected_volumes)
|
||||
result = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(result, expected_volumes)
|
||||
|
||||
@test.create_mocks({api.cinder: ['volume_get', 'volume_reset_state']})
|
||||
def test_update_volume_status(self):
|
||||
|
@ -48,66 +48,66 @@ class VolumeBackupsViewTests(test.TestCase):
|
||||
|
||||
@override_settings(API_RESULT_PAGE_SIZE=1)
|
||||
def test_backups_index_paginated(self):
|
||||
mox_backups = self.cinder_volume_backups.list()
|
||||
backups = self.cinder_volume_backups.list()
|
||||
size = settings.API_RESULT_PAGE_SIZE
|
||||
base_url = INDEX_URL
|
||||
next = backup_tables.BackupsTable._meta.pagination_param
|
||||
|
||||
# get first page
|
||||
expected_backups = mox_backups[:size]
|
||||
expected_backups = backups[:size]
|
||||
res = self._test_backups_index_paginated(
|
||||
marker=None, sort_dir="desc", backups=expected_backups,
|
||||
url=base_url, has_more=True, has_prev=False)
|
||||
backups = res.context['volume_backups_table'].data
|
||||
self.assertItemsEqual(backups, expected_backups)
|
||||
result = res.context['volume_backups_table'].data
|
||||
self.assertItemsEqual(result, expected_backups)
|
||||
|
||||
# get second page
|
||||
expected_backups = mox_backups[size:2 * size]
|
||||
expected_backups = backups[size:2 * size]
|
||||
marker = expected_backups[0].id
|
||||
|
||||
url = base_url + "?%s=%s" % (next, marker)
|
||||
res = self._test_backups_index_paginated(
|
||||
marker=marker, sort_dir="desc", backups=expected_backups, url=url,
|
||||
has_more=True, has_prev=True)
|
||||
backups = res.context['volume_backups_table'].data
|
||||
self.assertItemsEqual(backups, expected_backups)
|
||||
result = res.context['volume_backups_table'].data
|
||||
self.assertItemsEqual(result, expected_backups)
|
||||
|
||||
# get last page
|
||||
expected_backups = mox_backups[-size:]
|
||||
expected_backups = backups[-size:]
|
||||
marker = expected_backups[0].id
|
||||
url = base_url + "?%s=%s" % (next, marker)
|
||||
res = self._test_backups_index_paginated(
|
||||
marker=marker, sort_dir="desc", backups=expected_backups, url=url,
|
||||
has_more=False, has_prev=True)
|
||||
backups = res.context['volume_backups_table'].data
|
||||
self.assertItemsEqual(backups, expected_backups)
|
||||
result = res.context['volume_backups_table'].data
|
||||
self.assertItemsEqual(result, expected_backups)
|
||||
|
||||
@override_settings(API_RESULT_PAGE_SIZE=1)
|
||||
def test_backups_index_paginated_prev_page(self):
|
||||
mox_backups = self.cinder_volume_backups.list()
|
||||
backups = self.cinder_volume_backups.list()
|
||||
size = settings.API_RESULT_PAGE_SIZE
|
||||
base_url = INDEX_URL
|
||||
prev = backup_tables.BackupsTable._meta.prev_pagination_param
|
||||
|
||||
# prev from some page
|
||||
expected_backups = mox_backups[size:2 * size]
|
||||
expected_backups = backups[size:2 * size]
|
||||
marker = expected_backups[0].id
|
||||
url = base_url + "?%s=%s" % (prev, marker)
|
||||
res = self._test_backups_index_paginated(
|
||||
marker=marker, sort_dir="asc", backups=expected_backups, url=url,
|
||||
has_more=True, has_prev=True)
|
||||
backups = res.context['volume_backups_table'].data
|
||||
self.assertItemsEqual(backups, expected_backups)
|
||||
result = res.context['volume_backups_table'].data
|
||||
self.assertItemsEqual(result, expected_backups)
|
||||
|
||||
# back to first page
|
||||
expected_backups = mox_backups[:size]
|
||||
expected_backups = backups[:size]
|
||||
marker = expected_backups[0].id
|
||||
url = base_url + "?%s=%s" % (prev, marker)
|
||||
res = self._test_backups_index_paginated(
|
||||
marker=marker, sort_dir="asc", backups=expected_backups, url=url,
|
||||
has_more=True, has_prev=False)
|
||||
backups = res.context['volume_backups_table'].data
|
||||
self.assertItemsEqual(backups, expected_backups)
|
||||
result = res.context['volume_backups_table'].data
|
||||
self.assertItemsEqual(result, expected_backups)
|
||||
|
||||
@test.create_mocks({api.cinder: ('volume_backup_create',
|
||||
'volume_get')})
|
||||
|
@ -149,61 +149,61 @@ class VolumeIndexViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
|
||||
|
||||
@override_settings(API_RESULT_PAGE_SIZE=2)
|
||||
def test_index_paginated(self):
|
||||
mox_volumes = self.ensure_attachments_exist(self.cinder_volumes.list())
|
||||
volumes = self.ensure_attachments_exist(self.cinder_volumes.list())
|
||||
size = settings.API_RESULT_PAGE_SIZE
|
||||
|
||||
# get first page
|
||||
expected_volumes = mox_volumes[:size]
|
||||
expected_volumes = volumes[:size]
|
||||
url = INDEX_URL
|
||||
res = self._test_index_paginated(None, "desc", expected_volumes, url,
|
||||
True, False)
|
||||
volumes = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(volumes, expected_volumes)
|
||||
result = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(result, expected_volumes)
|
||||
|
||||
# get second page
|
||||
expected_volumes = mox_volumes[size:2 * size]
|
||||
expected_volumes = volumes[size:2 * size]
|
||||
marker = expected_volumes[0].id
|
||||
next = volume_tables.VolumesTable._meta.pagination_param
|
||||
url = "?".join([INDEX_URL, "=".join([next, marker])])
|
||||
res = self._test_index_paginated(marker, "desc", expected_volumes, url,
|
||||
True, True)
|
||||
volumes = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(volumes, expected_volumes)
|
||||
result = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(result, expected_volumes)
|
||||
|
||||
# get last page
|
||||
expected_volumes = mox_volumes[-size:]
|
||||
expected_volumes = volumes[-size:]
|
||||
marker = expected_volumes[0].id
|
||||
next = volume_tables.VolumesTable._meta.pagination_param
|
||||
url = "?".join([INDEX_URL, "=".join([next, marker])])
|
||||
res = self._test_index_paginated(marker, "desc", expected_volumes, url,
|
||||
False, True)
|
||||
volumes = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(volumes, expected_volumes)
|
||||
result = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(result, expected_volumes)
|
||||
|
||||
@override_settings(API_RESULT_PAGE_SIZE=2)
|
||||
def test_index_paginated_prev_page(self):
|
||||
mox_volumes = self.ensure_attachments_exist(self.cinder_volumes.list())
|
||||
volumes = self.ensure_attachments_exist(self.cinder_volumes.list())
|
||||
size = settings.API_RESULT_PAGE_SIZE
|
||||
|
||||
# prev from some page
|
||||
expected_volumes = mox_volumes[size:2 * size]
|
||||
expected_volumes = volumes[size:2 * size]
|
||||
marker = expected_volumes[0].id
|
||||
prev = volume_tables.VolumesTable._meta.prev_pagination_param
|
||||
url = "?".join([INDEX_URL, "=".join([prev, marker])])
|
||||
res = self._test_index_paginated(marker, "asc", expected_volumes, url,
|
||||
True, True)
|
||||
volumes = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(volumes, expected_volumes)
|
||||
result = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(result, expected_volumes)
|
||||
|
||||
# back to first page
|
||||
expected_volumes = mox_volumes[:size]
|
||||
expected_volumes = volumes[:size]
|
||||
marker = expected_volumes[0].id
|
||||
prev = volume_tables.VolumesTable._meta.prev_pagination_param
|
||||
url = "?".join([INDEX_URL, "=".join([prev, marker])])
|
||||
res = self._test_index_paginated(marker, "asc", expected_volumes, url,
|
||||
True, False)
|
||||
volumes = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(volumes, expected_volumes)
|
||||
result = res.context['volumes_table'].data
|
||||
self.assertItemsEqual(result, expected_volumes)
|
||||
|
||||
|
||||
class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
|
||||
|
Loading…
x
Reference in New Issue
Block a user