def test_tables_sort(test_item, soft_assert, appliance): view = navigate_to( (test_item.obj if test_item.obj is ContainersProvider else getattr( appliance.collections, test_item.collection_name)), 'All') view.toolbar.view_selector.select('List View') view.entities.paginator.set_items_per_page(1000) for col, header_text in enumerate(view.entities.elements.headers): if not header_text: continue # Checking both orders view.entities.elements.sort_by(column=header_text, order='asc') # sorted_by returns attributized string # in CFME 5.8, the sort on IP Address column for container providers fails to sort? soft_assert((view.entities.elements.sorted_by == attributize_string(header_text) and view.entities.elements.sort_order == 'asc'), 'Failed checking sorted_by {} and sort_order asc'.format( header_text)) rows_ascending = [r[col].text for r in view.entities.elements.rows()] # opposite sort order view.entities.elements.sort_by(column=header_text, order='desc') soft_assert((view.entities.elements.sorted_by == attributize_string(header_text) and view.entities.elements.sort_order == 'desc'), 'Failed checking sorted_by {} and sort_order desc'.format( header_text)) rows_descending = [r[col].text for r in view.entities.elements.rows()] soft_assert( rows_ascending[::-1] == rows_descending, 'Malfunction in the table sort: {} != {}'.format( rows_ascending[::-1], rows_descending))
def test_tables_sort(test_item, soft_assert, appliance): view = navigate_to((test_item.obj if test_item.obj is ContainersProvider else getattr(appliance.collections, test_item.collection_name)), 'All') view.toolbar.view_selector.select('List View') view.entities.paginator.set_items_per_page(1000) for col, header_text in enumerate(view.entities.elements.headers): if not header_text: continue # Checking both orders view.entities.elements.sort_by(column=header_text, order='asc') # sorted_by returns attributized string # in CFME 5.8, the sort on IP Address column for container providers fails to sort? soft_assert((view.entities.elements.sorted_by == attributize_string(header_text) and view.entities.elements.sort_order == 'asc'), 'Failed checking sorted_by {} and sort_order asc'.format(header_text)) rows_ascending = [r[col].text for r in view.entities.elements.rows()] # opposite sort order view.entities.elements.sort_by(column=header_text, order='desc') soft_assert((view.entities.elements.sorted_by == attributize_string(header_text) and view.entities.elements.sort_order == 'desc'), 'Failed checking sorted_by {} and sort_order desc'.format(header_text)) rows_descending = [r[col].text for r in view.entities.elements.rows()] soft_assert( rows_ascending[::-1] == rows_descending, 'Malfunction in the table sort: {} != {}'.format( rows_ascending[::-1], rows_descending ) )
def test_containers_summary_objects(provider, soft_assert): """ Containers overview page > Widgets > Widgets summary This test checks that the amount of a selected object in the system is shown correctly in the widgets in the Overview menu Steps: * Goes to Compute --> Containers --> Overview * Checks how many objects are shown in the selected widget * Goes to Containers summary page and checks how many objects are shown there. * Checks the amount is equal """ navigate_to(ContainersOverview, 'All') # Collecting status boxes values: status_box_values = { obj: StatusBox(obj.PLURAL.split(' ')[-1]).value() for obj in tested_objects } # Comparing to the values in the relationships tables: for obj in tested_objects: sb_val = status_box_values[obj] ui_val = getattr(provider.summary.relationships, attributize_string(obj.PLURAL)).value soft_assert( sb_val == ui_val, '{}: Mismatch between status box ({}) value in Containers overview' 'and provider\'s relationships table ({}):'.format( obj.PLURAL, sb_val, ui_val))
def test_widget_init(test_view, widget_name): """Test basic instantiation of the widgets in a view. When a View like this is defined: ``` class MyView(View): btn = Button(id="some_id") view = MyView(browser) ``` The Button.__init__ seem to be delayed until the view.btn is accessed. We got the view as the test_view fixture, so we now need to access it to check it won't produce an exception.""" assert getattr(test_view, attributize_string(widget_name))
def sort_by(self, column, order='asc'): """Sort table by column and in given direction. Args: column: Name of the column, can be normal or attributized. order: Sorting order. ``asc`` or ``desc``. """ self.logger.info('sort_by(%r, %r)', column, order) column = attributize_string(column) # Sort column if self.sorted_by != column: self.click_sort(column) else: self.logger.debug('sort_by(%r, %r): column already selected', column, order) # Sort order if self.sort_order != order: self.logger.info('sort_by(%r, %r): changing the sort order', column, order) self.click_sort(column) self.logger.debug('sort_by(%r, %r): order already selected', column, order)
def test_containers_summary_objects(provider, soft_assert): """ Containers overview page > Widgets > Widgets summary This test checks that the amount of a selected object in the system is shown correctly in the widgets in the Overview menu Steps: * Goes to Compute --> Containers --> Overview * Checks how many objects are shown in the selected widget * Goes to Containers summary page and checks how many objects are shown there. * Checks the amount is equal """ navigate_to(ContainersOverview, 'All') # Collecting status boxes values: status_box_values = {obj: StatusBox(obj.PLURAL.split(' ')[-1]).value() for obj in tested_objects} # Comparing to the values in the relationships tables: for obj in tested_objects: sb_val = status_box_values[obj] ui_val = getattr(provider.summary.relationships, attributize_string(obj.PLURAL)).value soft_assert(sb_val == ui_val, '{}: Mismatch between status box ({}) value in Containers overview' 'and provider\'s relationships table ({}):' .format(obj.PLURAL, sb_val, ui_val))
def attributized_headers(self): """Contains mapping between attributized headers and pretty headers""" return {attributize_string(h): h for h in self.headers if h is not None}
def sort_column(self, field, order="asc"): field = attributize_string(field) view = navigate_to(self, "Details") view.data_view.table.sort_by(field, order=order) assert view.data_view.table.sorted_by == field assert view.data_view.table.sort_order == order
def test_widget_stringification(test_view, widget_name): """Tests whether the widget can be stringified. All the widgets that can be instantiated should be able to stringify.""" wgt = getattr(test_view, attributize_string(widget_name)) assert isinstance(str(wgt), str) assert isinstance(repr(wgt), str)
] REPORTS = [ "Host CPU Trends (last week)", "Host Memory Trends (last week)", "Offline VMs with Snapshot", "Top CPU Consumers (weekly)", "Top Memory Consumers (weekly)", "VMs with Volume Free Space >= 75%", ] @pytest.mark.meta(automates=[1769346]) @pytest.mark.parametrize("menu_name", REPORTS, ids=[attributize_string(i) for i in REPORTS]) def test_generate_optimization_report(appliance, menu_name): """ Bugzilla: 1769346 Polarion: assignee: pvala initialEstimate: 1/8h casecomponent: Reporting tags: reports startsin: 5.11 testSteps: 1. Navigate to Overview > Optimization and queue the report with parametrized menu_name. 2. Check if the report exists. """
def click_sort(self, column): """Clicks the sorting link in the given column. The column gets attributized.""" self.logger.info('click_sort(%r)', column) column = attributize_string(column) column_position = self.header_index_mapping[self.attributized_headers[column]] self.browser.click(self.SORT_LINK.format(column_position + 1), parent=self)
def sorted_by(self): """Returns the name of column that the table is sorted by. Attributized!""" return attributize_string(self.browser.text(self.SORTED_BY_LOC, parent=self))
from cfme.utils.blockers import BZ pytestmark = [test_requirements.report, pytest.mark.tier(1), pytest.mark.ignore_stream("5.10")] REPORTS = [ "Host CPU Trends (last week)", "Host Memory Trends (last week)", "Offline VMs with Snapshot", "Top CPU Consumers (weekly)", "Top Memory Consumers (weekly)", "VMs with Volume Free Space >= 75%", ] @pytest.mark.meta(automates=[1769346]) @pytest.mark.parametrize("menu_name", REPORTS, ids=[attributize_string(i) for i in REPORTS]) def test_generate_optimization_report(appliance, menu_name): """ Bugzilla: 1769346 Polarion: assignee: pvala initialEstimate: 1/8h casecomponent: Reporting tags: reports startsin: 5.11 testSteps: 1. Navigate to Overview > Optimization and queue the report with parametrized menu_name. 2. Check if the report exists. """