Change TestImageAdmin to test proper pages
Previously the essence of TestImageAdmin was to do the same things on same pages, but under a different (admin) user. We realized that it's not very useful since admin user in Horizon under no circumstances has less rights than a regular user. A saner approach under admin user would be to test pages inaccessible to a regular user - that's done in this patch. Also is_*_link_available() functions were sligthly improved: they no longer wait a default timeout for the link to appear, because by the time these methods are invoked table links are already visible for sure or are expected to be misssing. Implements blueprint: horizon-integration-tests-coverage Change-Id: Idd0c871706d2a8c2c61d6182bbd533bba141baa9
This commit is contained in:
parent
d1f08df329
commit
457935c3d3
@ -129,10 +129,18 @@ class TableRegion(baseregion.BaseRegion):
|
||||
for elem in self._get_elements(*self._rows_locator)]
|
||||
|
||||
def is_next_link_available(self):
|
||||
try:
|
||||
self._turn_off_implicit_wait()
|
||||
return self._is_element_visible(*self._next_locator)
|
||||
finally:
|
||||
self._turn_on_implicit_wait()
|
||||
|
||||
def is_prev_link_available(self):
|
||||
try:
|
||||
self._turn_off_implicit_wait()
|
||||
return self._is_element_visible(*self._prev_locator)
|
||||
finally:
|
||||
self._turn_on_implicit_wait()
|
||||
|
||||
def turn_next_page(self):
|
||||
if self.is_next_link_available():
|
||||
|
@ -14,7 +14,13 @@ from openstack_dashboard.test.integration_tests import helpers
|
||||
from openstack_dashboard.test.integration_tests.regions import messages
|
||||
|
||||
|
||||
class ImagesTestMixin(object):
|
||||
class TestImages(helpers.TestCase):
|
||||
"""Login as demo user"""
|
||||
IMAGE_NAME = helpers.gen_random_resource_name("image")
|
||||
|
||||
@property
|
||||
def images_page(self):
|
||||
return self.home_pg.go_to_compute_imagespage()
|
||||
|
||||
def test_image_create_delete(self):
|
||||
"""tests the image creation and deletion functionalities:
|
||||
@ -23,7 +29,7 @@ class ImagesTestMixin(object):
|
||||
* deletes the newly created image
|
||||
* verifies the image does not appear in the table after deletion
|
||||
"""
|
||||
images_page = self.home_pg.go_to_compute_imagespage()
|
||||
images_page = self.images_page
|
||||
|
||||
images_page.create_image(self.IMAGE_NAME)
|
||||
self.assertTrue(images_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
@ -36,11 +42,6 @@ class ImagesTestMixin(object):
|
||||
self.assertFalse(images_page.find_message_and_dismiss(messages.ERROR))
|
||||
self.assertFalse(images_page.is_image_present(self.IMAGE_NAME))
|
||||
|
||||
|
||||
class TestImage(helpers.TestCase, ImagesTestMixin):
|
||||
"""Login as demo user"""
|
||||
IMAGE_NAME = helpers.gen_random_resource_name("image")
|
||||
|
||||
def test_images_pagination(self):
|
||||
"""This test checks images pagination
|
||||
Steps:
|
||||
@ -74,7 +75,7 @@ class TestImage(helpers.TestCase, ImagesTestMixin):
|
||||
settings_page.change_pagesize(items_per_page)
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
|
||||
images_page = self.home_pg.go_to_compute_imagespage()
|
||||
images_page = self.images_page
|
||||
images_page.images_table.assert_definition(first_page_definition)
|
||||
|
||||
images_page.images_table.turn_next_page()
|
||||
@ -94,58 +95,10 @@ class TestImage(helpers.TestCase, ImagesTestMixin):
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
|
||||
|
||||
class TestImageAdmin(helpers.AdminTestCase, ImagesTestMixin):
|
||||
class TestImagesAdmin(helpers.AdminTestCase, TestImages):
|
||||
"""Login as admin user"""
|
||||
IMAGE_NAME = helpers.gen_random_resource_name("image")
|
||||
|
||||
def test_images_pagination_under_admin(self):
|
||||
"""This test checks images pagination under admin user
|
||||
Steps:
|
||||
1) Login to Horizon Dashboard as admin user
|
||||
2) Navigate to user settings page
|
||||
3) Change 'Items Per Page' value to 1
|
||||
4) Go to Admin -> System -> Images page
|
||||
5) Check that only 'Next' link is available, only one image is
|
||||
available (and it has correct name)
|
||||
6) Click 'Next' and check that both 'Prev' and 'Next' links are
|
||||
available, only one image is available (and it has correct name)
|
||||
7) Click 'Next' and check that only 'Prev' link is available,
|
||||
only one image is visible (and it has correct name)
|
||||
8) Click 'Prev' and check results (should be the same as for step6)
|
||||
9) Click 'Prev' and check results (should be the same as for step5)
|
||||
10) Go to user settings page and restore 'Items Per Page'
|
||||
"""
|
||||
default_image_list = self.CONFIG.image.images_list
|
||||
items_per_page = 1
|
||||
first_page_definition = {'Next': True, 'Prev': False,
|
||||
'Count': items_per_page,
|
||||
'Names': [default_image_list[0]]}
|
||||
second_page_definition = {'Next': True, 'Prev': True,
|
||||
'Count': items_per_page,
|
||||
'Names': [default_image_list[1]]}
|
||||
third_page_definition = {'Next': False, 'Prev': True,
|
||||
'Count': items_per_page,
|
||||
'Names': [default_image_list[2]]}
|
||||
|
||||
settings_page = self.home_pg.go_to_settings_usersettingspage()
|
||||
settings_page.change_pagesize(items_per_page)
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
|
||||
images_page = self.home_pg.go_to_system_imagespage()
|
||||
images_page.images_table.assert_definition(first_page_definition)
|
||||
|
||||
images_page.images_table.turn_next_page()
|
||||
images_page.images_table.assert_definition(second_page_definition)
|
||||
|
||||
images_page.images_table.turn_next_page()
|
||||
images_page.images_table.assert_definition(third_page_definition)
|
||||
|
||||
images_page.images_table.turn_prev_page()
|
||||
images_page.images_table.assert_definition(second_page_definition)
|
||||
|
||||
images_page.images_table.turn_prev_page()
|
||||
images_page.images_table.assert_definition(first_page_definition)
|
||||
|
||||
settings_page = self.home_pg.go_to_settings_usersettingspage()
|
||||
settings_page.change_pagesize()
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
@property
|
||||
def images_page(self):
|
||||
return self.home_pg.go_to_system_imagespage()
|
||||
|
Loading…
Reference in New Issue
Block a user