def test_bug_lookup_fails(self): """Assert ``False`` is returned if the bug cannot be found.""" def bomb(_): """A function that mocks a failure to fetch a bug.""" raise decorators.BugFetchError decorators._get_redmine_bug_status_id = bomb self.assertFalse(decorators.rm_bug_is_open(self.bug_id))
def ui_entities(module_org, module_loc): """Collects the list of all applicable UI entities for testing and does all required preconditions. """ ui_entities = [] for entity in BOOKMARK_ENTITIES: # Skip the entities, which can't be tested ATM (not implemented in # airgun or have open BZs) skip = entity.get('skip_for_ui') if isinstance(skip, tuple): bug_type, bug_id = skip if (bug_type == 'bugzilla' and bz_bug_is_open(bug_id) or bug_type == 'redmine' and rm_bug_is_open(bug_id)): skip = True if skip is True: continue ui_entities.append(entity) # Some pages require at least 1 existing entity for search bar to # appear. Creating 1 entity for such pages entity_name, entity_setup = entity['name'], entity.get('setup') if entity_setup: # entities with 1 organization and location if entity_name in ('Host', ): entity_setup(organization=module_org, location=module_loc).create() # entities with no organizations and locations elif entity_name in ('ComputeProfile', 'ConfigGroup', 'GlobalParameter', 'HardwareModel', 'PuppetClass', 'UserGroup'): entity_setup().create() # entities with multiple organizations and locations else: entity_setup(organization=[module_org], location=[module_loc]).create() return ui_entities
def setUpClass(cls): """Create an organization and an activation key belonging to it.""" super(ActivationKeySearchTestCase, cls).setUpClass() cls.org = entities.Organization().create() cls.act_key = entities.ActivationKey(organization=cls.org).create() if rm_bug_is_open(4638): cls.act_key.read() # Wait for elasticsearch to index new act key.
def search(self, name): """Searches existing discovery rule from UI. It is necessary to use custom search as we don't have both search bar and search button there. """ if not rm_bug_is_open(9021): raise DeprecationWarning( 'Search box is implemented. Use generic search method') self.navigate_to_entity() strategy, value = self._search_locator() if len(name) > 32: strategy, value = common_locators['select_filtered_entity'] return self.wait_until_element((strategy, value % name))
def search(self, name): """Searches existing discovery rule from UI. It is necessary to use custom search as we don't have both search bar and search button there. """ if not rm_bug_is_open(9021): raise DeprecationWarning( 'Search box is implemented. Use generic search method' ) self.navigate_to_entity() strategy, value = self._search_locator() if len(name) > 32: strategy, value = common_locators['select_filtered_entity'] return self.wait_until_element((strategy, value % name))
def setUpClass(cls): """Display all the bookmarks on the same page, create user and entities for testing. """ super(BookmarkTestCase, cls).setUpClass() cls.entities = [] # Custom user for bookmark visibility testing role = entities.Role().search(query={'search': 'name="Viewer"'})[0] cls.custom_password = gen_string('alphanumeric') cls.custom_user = entities.User( role=[role], password=cls.custom_password, ).create() for entity in BOOKMARK_ENTITIES: # Skip the entities, which can't be tested ATM (require framework # update) skip = entity.get('skip_for_ui') if isinstance(skip, tuple): if (skip[0] == 'bugzilla' and bz_bug_is_open(skip[1]) or skip[0] == 'redmine' and rm_bug_is_open(skip[1])): skip = True if skip is True: continue cls.entities.append(entity) # Some pages require at least 1 existing entity for search bar to # appear. Creating 1 entity for such pages if entity.get('setup'): # entities with 1 organization if entity['name'] in ('Hosts',): entity['setup'](organization=cls.session_org).create() # entities with no organizations elif entity['name'] in ( 'Compute_Profile', 'ConfigGroups', 'GlobalParameters', 'HardwareModel', 'PuppetClasses', 'UserGroup'): entity['setup']().create() # entities with multiple organizations else: entity['setup'](organization=[cls.session_org]).create()
def test_bug_is_closed(self): """Assert ``False`` is returned if the bug is closed.""" decorators._get_redmine_bug_status_id = lambda bug_id: 1 self.assertFalse(decorators.rm_bug_is_open(self.bug_id)) decorators._get_redmine_bug_status_id = lambda bug_id: 2 self.assertFalse(decorators.rm_bug_is_open(self.bug_id))
def test_bug_is_open(self): """Assert ``True`` is returned if the bug is open.""" decorators._get_redmine_bug_status_id = lambda bug_id: 0 self.assertTrue(decorators.rm_bug_is_open(self.bug_id)) decorators._get_redmine_bug_status_id = lambda bug_id: 3 self.assertTrue(decorators.rm_bug_is_open(self.bug_id))