internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: ManageIQ/integration_tests

Issue:
events.html is written whether event testing is enabled or not
Based on [this conditional](https://github.com/RedHatQE/cfme_tests/blob/c2b0465e8f201818fe4b2aff85855d96d04f5532/fixtures/events.py#L302), I would expect no report to be generated if event testing is disabled, but for some reason events.html is being generated.

@mfalesni Any ideas what's going on here?



Discussion:

Resolving patch:
diff --git a/fixtures/events.py b/fixtures/events.py
--- a/fixtures/events.py
+++ b/fixtures/events.py
@@ -36,7 +36,7 @@ def generate(self, filename):
 
 class EventExpectation(object):
     """ Expectation for an event.
-    
+
     This object embeds an expectation in order to be able to easily compare
     whether the two expectations are the same but just with different time.
     """
@@ -89,14 +89,14 @@ class EventListener(object):
 
     TIME_FORMAT = "%Y-%m-%d-%H-%M-%S"
 
-    def __init__(self, listener_port, settle_time, results_file="test_events.log"):
+    def __init__(self, listener_port, settle_time, log_file="test_events.log"):
         self.cfme_data = load_cfme_data()
         self.listener_port = int(listener_port)
         listener_filename = local(__file__).new(basename='../scripts/listener.py').strpath
         self.listener_script = "%s %d" % (listener_filename, self.listener_port)
         self.settle_time = int(settle_time)
         self.expectations = []
-        logging.basicConfig(filename=results_file, level=logging.INFO)
+        logging.basicConfig(filename=log_file, level=logging.INFO)
         self.listener = None
 
     def get_listener_host(self):
@@ -268,7 +268,14 @@ def listener_info(self):
         It is used in setup test cases located at:
         ``/tests/test_setup_event_testing.py``
         """
-        return type("Listener", (object,), {"host": self.get_listener_host(), "port": self.listener_port})
+        return type(
+            "Listener",
+            (object,),
+            {
+                "host": self.get_listener_host(),
+                "port": self.listener_port
+            }
+        )
 
     @property
     def finished(self):
@@ -350,8 +357,7 @@ def pytest_configure(config):
     If the testing is enabled, listener is started.
     """
     plugin = EventListener(config.getoption("event_testing_port"),
-                           config.getoption("event_testing_settletime"),
-                           config.getoption("event_testing_result"))
+                           config.getoption("event_testing_settletime"))
     registration = config.pluginmanager.register(plugin, "event_testing")
     assert registration
     if config.getoption("event_testing_enabled"):


Test patch:
Repository: ManageIQ/integration_tests

Issue:
[pytest_selenium.py] Date input
- Added possibility to enter the date as tuple (Y, M, D)
- In addition to this, possibility to set the read-only date input was added
- And to support all of this, a function to get all attributes from element has been added



Discussion:

Resolving patch:
diff --git a/cfme/web_ui/__init__.py b/cfme/web_ui/__init__.py
--- a/cfme/web_ui/__init__.py
+++ b/cfme/web_ui/__init__.py
@@ -28,6 +28,7 @@
 import os
 import re
 import types
+from datetime import date
 
 import selenium
 from selenium.common import exceptions as sel_exceptions
@@ -427,6 +428,43 @@ def _sd_fill_otext(ot, value):
     sel.set_text(ot, value)
 
 
+class Calendar(object):
+    """A CFME calendar form field
+
+    Calendar fields are readonly, and managed by the dxhtmlCalendar widget. A Calendar field
+    will accept any object that can be coerced into a string, but the value may not match the format
+    expected by dhtmlxCalendar or CFME. For best results, either a ``datetime.date`` or
+    ``datetime.datetime`` object should be used to create a valid date field.
+
+    Args:
+        name: "name" property of the readonly calendar field.
+
+    Usage:
+
+        calendar = web_ui.Calendar("miq_date_1")
+        web_ui.fill(calendar, date(2000, 1, 1))
+        web_ui.fill(calendar, '1/1/2001')
+
+    """
+    def __init__(self, name):
+        self.name = name
+
+    def locate(self):
+        return '//input[@name="%s"]' % self.name
+
+
+@fill.register(Calendar)
+def _sd_fill_date(calendar, value):
+    input = sel.element(calendar)
+    if isinstance(value, date):
+        date_str = '%s/%s/%s' % (value.month, value.day, value.year)
+    else:
+        date_str = str(value)
+
+    # need to write to a readonly field: resort to evil
+    browser().execute_script("arguments[0].value = '%s'" % date_str, input)
+
+
 @fill.register(types.NoneType)
 def _sd_fill_none(*args, **kwargs):
     """ Ignore a NoneType """


Test patch:
Repository: ManageIQ/integration_tests

Issue:
Paginator returns wrong rec_end() result
When record is last one on it's own on the last page, rec_end() incorrectly shows 1, instead of rec_total() value.



Discussion:

Resolving patch:
diff --git a/cfme/web_ui/paginator.py b/cfme/web_ui/paginator.py
--- a/cfme/web_ui/paginator.py
+++ b/cfme/web_ui/paginator.py
@@ -78,7 +78,7 @@ def rec_end():
     if offset:
         return offset.groups()[0]
     else:
-        return '1'
+        return rec_total()
 
 
 def rec_total():


Test patch:
Repository: ManageIQ/integration_tests

Issue:
NoSuchElementException when server_roles = None
Attempting to limit an appliance's roles using server_roles = None to turn off everything except the UI role results in an error.

`[E] NoSuchElementException: Message: Element input#server_roles_storage_metrics_processor not found on page. (fixtures/log.py:61)`

Furthermore it does it the old fashion way rather than validating via the database.  You can still accomplish limited a fresh appliance to the UI role via:

`server_roles="-database_operations -event -ems_inventory -ems_operations -reporting  -scheduler -smartstate -web_services"`



Discussion:
That is because the storage options are not there unless the storage option is enabled. I'll look in it.


Resolving patch:
diff --git a/cfme/configure/configuration/__init__.py b/cfme/configure/configuration/__init__.py
--- a/cfme/configure/configuration/__init__.py
+++ b/cfme/configure/configuration/__init__.py
@@ -1592,6 +1592,15 @@ def set_server_roles(**roles):
     Args:
         **roles: Roles specified as in server_roles Form in this module. Set to True or False
     """
+    cfg = store.current_appliance.get_yaml_config('vmdb')
+    # If we don't have storage enabled, ignore it.
+    if 'storage' not in cfg.get('product', {}):
+        delete_keys = set([])
+        for key in roles:
+            if key.startswith("storage"):
+                delete_keys.add(key)
+        for key in delete_keys:
+            roles.pop(key)
     if get_server_roles() == roles:
         logger.debug(' Roles already match, returning...')
         return


Test patch:
Repository: ManageIQ/integration_tests

Issue:
Fix add host from 55+
{{pytest: -k test_button_on_host --disablemetaplugins blockers --long-running }}



Discussion:
Disabled blockers plugin to remove the ssl error and added long-running to retest.


Resolving patch:
diff --git a/cfme/infrastructure/host.py b/cfme/infrastructure/host.py
--- a/cfme/infrastructure/host.py
+++ b/cfme/infrastructure/host.py
@@ -42,7 +42,9 @@
         ('hostname_text', Input("hostname")),
         ('ipaddress_text', Input("ipaddress"), {"removed_since": "5.4.0.0.15"}),
         ('custom_ident_text', Input("custom")),
-        ('host_platform', Select('//select[@id="user_assigned_os"]')),
+        ('host_platform', {
+            version.LOWEST: Select('//select[@id="user_assigned_os"]'),
+            '5.5': AngularSelect('user_assigned_os')}),
         ('ipmi_address_text', Input("ipmi_address")),
         ('mac_address_text', Input("mac_address")),
     ])
@@ -79,7 +81,10 @@
     "5.4": "//th[normalize-space(.)='Timestamp']/ancestor::table[1]"
 })
 
-host_add_btn = FormButton('Add this Host')
+host_add_btn = {
+    version.LOWEST: FormButton('Add this Host'),
+    "5.5": FormButton("Add")
+}
 cfg_btn = partial(tb.select, 'Configuration')
 pol_btn = partial(tb.select, 'Policy')
 pow_btn = partial(tb.select, 'Power')


Test patch:
Repository: ManageIQ/integration_tests

Issue:
Remove pytest references from usage framework
https://github.com/lehinevych/cfme_tests/blob/templates_rest/cfme/rest/__init__.py - can we remove the skips in here. This code should raise and Exception which should be caught in the test/fixture code.



Discussion:
@lehinevych 


Resolving patch:
diff --git a/cfme/rest/__init__.py b/cfme/rest/__init__.py
--- a/cfme/rest/__init__.py
+++ b/cfme/rest/__init__.py
@@ -1,7 +1,7 @@
 import fauxfactory
-import pytest
 
 from cfme.automate.service_dialogs import ServiceDialog
+from cfme.exceptions import OptionNotAvailable
 from cfme.services.catalogs.catalog_item import CatalogItem
 from cfme.services.catalogs.service_catalogs import ServiceCatalogs
 from cfme.services import requests
@@ -157,7 +157,7 @@ def services(request, rest_api, a_provider, dialog, service_catalogs):
         services = [_ for _ in rest_api.collections.services]
         services[0]
     except IndexError:
-        pytest.skip("There is no service to be taken")
+        raise Exception("No options are selected")
 
     @request.addfinalizer
     def _finished():
@@ -202,8 +202,6 @@ def a_provider():
 
 
 def vm(request, a_provider, rest_api):
-    if "refresh" not in rest_api.collections.providers.action.all:
-        pytest.skip("Refresh action is not implemented in this version")
     provider_rest = rest_api.collections.providers.get(name=a_provider.name)
     vm_name = deploy_template(
         a_provider.key,
@@ -234,7 +232,7 @@ def service_templates(request, rest_api, dialog):
         s_tpls = [_ for _ in rest_api.collections.service_templates]
         s_tpls[0]
     except IndexError:
-        pytest.skip("There is no service template to be taken")
+        raise Exception("There is no service template to be taken")
 
     @request.addfinalizer
     def _finished():
@@ -319,7 +317,8 @@ def users(request, rest_api, num=1):
 def _creating_skeleton(request, rest_api, col_name, col_data):
     collection = getattr(rest_api.collections, col_name)
     if "create" not in collection.action.all:
-        pytest.skip("Create action for {} is not implemented in this version".format(col_name))
+        raise OptionNotAvailable(
+            "Create action for {} is not implemented in this version".format(col_name))
     entities = collection.action.create(*col_data)
     for entity in col_data:
         if entity.get('name', None):


Test patch:
Repository: ManageIQ/integration_tests

Issue:
-m provider_related no longer works
We added the internally generated mark provider_related to be used in conjunction with --use-provider <provider> so we could only run tests that are specific to the provider.  Without it, the test collected would be anything non-parameterized through testgen, like general ui tests, along with the provider paramaterized tests specific to the provider that pass through testgen.  

Example (only run tests specific to rhevm36 provider integration):
py.test cfme/tests/infrastructure --use-provider rhevm36 -m provider_related

This appears to have broken at some point and need to be fixed.

A partial workaround is to pass "-m uses_testgen" instead.  It still pulls in some extra tests but limits it to test suites that use testgen.  For example, test_providers.py would run the specific crud tests but also run the provider validation tests which isn't ideal but far less than running without (when you only want to run the specific provider integration tests).  This all needs documentation in #3115 



Discussion:
a short term workaround would be to put a mark into the provider related test items,

i propose replacing `--use-provider foo -m provider_related` with a `--only-for-provider` option that does select only testgen based tests that use the specific provider


Resolving patch:
diff --git a/utils/testgen.py b/utils/testgen.py
--- a/utils/testgen.py
+++ b/utils/testgen.py
@@ -331,8 +331,6 @@ def pytest_generate_tests(metafunc):
 
     """
 
-    metafunc.function = pytest.mark.uses_testgen()(metafunc.function)
-
     argnames = []
     argvalues = []
     idlist = []
@@ -367,6 +365,7 @@ def pytest_generate_tests(metafunc):
             continue
 
         if 'provider' in metafunc.fixturenames and 'provider' not in argnames:
+            metafunc.function = pytest.mark.uses_testgen()(metafunc.function)
             argnames.append('provider')
 
         # uncollect when required field is not present and option['require_field'] == True


Test patch:
Repository: ManageIQ/integration_tests

Issue:
String interpolation with no params in utils.db
https://github.com/RedHatQE/cfme_tests/blob/master/utils/db.py#L297



Discussion:

Resolving patch:
diff --git a/utils/db.py b/utils/db.py
--- a/utils/db.py
+++ b/utils/db.py
@@ -281,7 +281,7 @@ def _table(self, table_name):
                 return table_cls
             except ArgumentError:
                 # This usually happens on join tables with no PKs
-                logger.info('Unable to create table class for table "%s"')
+                logger.info('Unable to create table class for table "{}"'.format(table_name))
                 return None
 
 


Test patch:
Repository: ManageIQ/integration_tests

Issue:
Widgetastic_manageIQ.CheckboxSelect Finds checkboxes outside of `search_root`
During testing of PR #4254 it was found that a CheckboxSelect defined as below was including checkboxes from the checkbox table in a different div than the given search_root div ID.
`status = CheckboxSelect(search_root='tasks_options_div')`

It looks like `CheckboxSelect.checkboxes()` method is not taking the ROOT into account, and many class methods depend on this method to function properly.


Discussion:

Resolving patch:
diff --git a/widgetastic_manageiq.py b/widgetastic_manageiq.py
--- a/widgetastic_manageiq.py
+++ b/widgetastic_manageiq.py
@@ -446,7 +446,7 @@ def __init__(self, parent, search_root, text_access_func=None, logger=None):
     def checkboxes(self):
         """All checkboxes."""
         return {Checkbox(self, id=el.get_attribute("id")) for el in self.browser.elements(
-            ".//input[@type='checkbox']")}
+            ".//input[@type='checkbox']", parent=self)}
 
     @property
     def selected_checkboxes(self):


Test patch:
Repository: ManageIQ/integration_tests

Issue:
Allow for DropdownDisabled exception during widgetastic_patternfly.Dropdown.close
When calling Dropdown.item_select() on some pages (collections) the dropdown may be disabled after the selection is made. `close` is called, and it only catches NoSuchElementException from _verify_enabled.

Change to also catch DropdownDisabled, and log with 'silent' failure.


Discussion:
@mfalesni Like PR #4367

Resolving patch:
diff --git a/widgetastic_patternfly.py b/widgetastic_patternfly.py
--- a/widgetastic_patternfly.py
+++ b/widgetastic_patternfly.py
@@ -1116,11 +1116,16 @@ def open(self):
             self.browser.click(self)
 
     def close(self, ignore_nonpresent=False):
+        """Close the dropdown
+
+        Args:
+            ignore_nonpresent: Will ignore exceptions due to disabled or missing dropdown
+        """
         try:
             self._verify_enabled()
             if self.is_open:
                 self.browser.click(self)
-        except NoSuchElementException:
+        except (NoSuchElementException, DropdownDisabled):
             if not ignore_nonpresent:
                 raise
 


Test patch:
Repository: ManageIQ/integration_tests

Issue:
In chargeback rate assignment - 'Add' button
In chargeback rate assignment form, when the form is filled and we are about to press the 'Add' (assignment) button, the Add button of the row is pressed instead:
Reproduction branch: https://github.com/gshefer/integration_tests/tree/chargeback_reports
Reproduction file: cfme/tests/containers/test_chargeback.py

![cfme chargeback](https://cloud.githubusercontent.com/assets/21076742/24146804/fc7f99f4-0e3f-11e7-9ca6-a505b1532157.png)



Discussion:
Yes, I will add additional matching conditions for the buttons, probably the classes on it. Not sure how we will do it with the gray add buttons, they will have to live in a sub-view fenced by a locator.

Resolving patch:
diff --git a/widgetastic_patternfly.py b/widgetastic_patternfly.py
--- a/widgetastic_patternfly.py
+++ b/widgetastic_patternfly.py
@@ -46,23 +46,46 @@ class DropdownItemNotFound(Exception):
 class Button(Widget, ClickableMixin):
     """A PatternFly/Bootstrap button
 
+    You can match by text, partial text or by attributes, you can also add the bootstrap classes
+    into the matching.
+
     .. code-block:: python
 
         Button('Text of button (unless it is an input ...)')
         Button('contains', 'Text of button (unless it is an input ...)')
         Button(title='Show xyz')  # And such
+        Button('Add', classes=[Button.PRIMARY])
         assert button.active
         assert not button.disabled
     """
     CHECK_VISIBILITY = True
 
+    # Classes usable in the constructor
+    # Button types
+    DEFAULT = 'btn-default'
+    PRIMARY = 'btn-primary'
+    SUCCESS = 'btn-success'
+    INFO = 'btn-info'
+    WARNING = 'btn-warning'
+    DANGER = 'btn-danger'
+    LINK = 'btn-link'
+
+    # Button sizes
+    LARGE = 'btn-lg'
+    MEDIUM = 'btn-md'
+    SMALL = 'btn-sm'
+    EXTRA_SMALL = 'btn-xs'
+
+    # Shape
+    BLOCK = 'btn-block'
+
     def __init__(self, parent, *text, **kwargs):
         logger = kwargs.pop('logger', None)
         Widget.__init__(self, parent, logger=logger)
         self.args = text
         self.kwargs = kwargs
         if text:
-            if kwargs:
+            if kwargs and 'classes' not in kwargs:
                 raise TypeError('If you pass button text then do not pass anything else.')
             if len(text) == 1:
                 self.locator_conditions = 'normalize-space(.)={}'.format(quote(text[0]))
@@ -74,6 +97,12 @@ def __init__(self, parent, *text, **kwargs):
             # Join the kwargs
             self.locator_conditions = ' and '.join(
                 '@{}={}'.format(attr, quote(value)) for attr, value in kwargs.items())
+        classes = kwargs.pop('classes', [])
+        if classes:
+            self.locator_conditions += ' and '
+            self.locator_conditions += ' and '.join(
+                'contains(@class, {})'.format(quote(klass))
+                for klass in classes)
 
     # TODO: Handle input value the same way as text for other tags
     def __locator__(self):


Test patch:
Repository: ManageIQ/integration_tests

Issue:
Can't add any Openstack provider with Ceilometer event source
Can't setup Openstack (both Infra and Cloud) provider using framework with `event_stream: Ceilometer`, because it tries to click on Validate button which doesn't exist for Ceilometer event source.



Discussion:

Resolving patch:
diff --git a/cfme/common/provider.py b/cfme/common/provider.py
--- a/cfme/common/provider.py
+++ b/cfme/common/provider.py
@@ -198,7 +198,8 @@ def create(self, cancel=False, validate_credentials=True, check_existing=False,
                             endp_view.fill(endpoint.credentials.view_value_mapping)
                         # sometimes we have cases that we need to validate even though
                         # there is no credentials, such as Hawkular endpoint
-                        if validate_credentials and hasattr(endp_view, 'validate'):
+                        if (validate_credentials and hasattr(endp_view, 'validate') and
+                                endp_view.validate.is_displayed):
                             # there are some endpoints which don't demand validation like
                             #  RSA key pair
                             endp_view.validate.click()
@@ -309,7 +310,8 @@ def update(self, updates, cancel=False, validate_credentials=True):
                             endp_view.fill(endpoint.credentials.view_value_mapping)
                     # sometimes we have cases that we need to validate even though
                     # there is no credentials, such as Hawkular endpoint
-                    if validate_credentials and hasattr(endp_view, 'validate'):
+                    if (validate_credentials and hasattr(endp_view, 'validate') and
+                            endp_view.validate.is_displayed):
                         endp_view.validate.click()
 
             # cloud rhos provider always requires validation of all endpoints
@@ -318,7 +320,8 @@ def update(self, updates, cancel=False, validate_credentials=True):
             if self.one_of(OpenStackProvider):
                 for endp in self.endpoints.values():
                     endp_view = getattr(self.endpoints_form(parent=edit_view), endp.name)
-                    endp_view.validate.click()
+                    if hasattr(endp_view, 'validate') and endp_view.validate.is_displayed:
+                        endp_view.validate.click()
 
             if self.one_of(InfraProvider):
                 details_view_obj = InfraProviderDetailsView


Test patch:
Repository: ManageIQ/integration_tests

Issue:
Validate Provider Credential Validation Flash Message
psav requested this issue, and may provide more context.

During provider create, the flash message generated by credentials validation should be checked/validated against the expected behavior and content.


Discussion:

Resolving patch:
diff --git a/cfme/common/provider.py b/cfme/common/provider.py
--- a/cfme/common/provider.py
+++ b/cfme/common/provider.py
@@ -203,6 +203,13 @@ def create(self, cancel=False, validate_credentials=True, check_existing=False,
                             # there are some endpoints which don't demand validation like
                             #  RSA key pair
                             endp_view.validate.click()
+                            # Flash message widget is in add_view, not in endpoints tab
+                            logger.info(
+                                'Validating credentials flash message for endpoint %s',
+                                endpoint_name)
+                            add_view.flash.assert_no_error()
+                            add_view.flash.assert_success_message(
+                                'Credential validation was successful')
                 if self.one_of(InfraProvider):
                     main_view_obj = InfraProvidersView
                 elif self.one_of(CloudProvider):
@@ -761,18 +768,6 @@ def ip_address(self, value):
         else:
             logger.warn("can't set ipaddress because default endpoint is absent")
 
-    def wait_for_creds_ok(self):
-        """Waits for provider's credentials to become O.K. (circumvents the summary rails exc.)"""
-        self.refresh_provider_relationships(from_list_view=True)
-
-        def _wait_f():
-            navigate_to(self, 'All')
-            q = Quadicon(self.name, self.quad_name)
-            creds = q.creds
-            return "checkmark" in creds
-
-        wait_for(_wait_f, num_sec=300, delay=5, message="credentials of {} ok!".format(self.name))
-
     @property
     def _assigned_policy_profiles(self):
         result = set([])


Test patch: