def tag(category): tag = Tag(name=generate_lowercase_random_string(size=8), display_name=generate_random_string(size=32), category=category) tag.create() yield tag tag.delete()
def new_tag(new_category): category = Category(name=new_category.name, display_name=new_category.display_name) tag = Tag(name="tag_vis_" + fauxfactory.gen_alphanumeric().lower(), display_name="tag_vis_" + fauxfactory.gen_alphanumeric().lower(), category=category) tag.create() yield tag tag.delete(cancel=False)
def tag(category): """ Returns random created tag object Object can be used in all test run session """ tag = Tag(name=fauxfactory.gen_alpha(8).lower(), display_name=fauxfactory.gen_alphanumeric(length=32), category=category) tag.create() yield tag tag.delete(False)
def get_tags_db(self): """ Gets tags detail from database Column order: `tag_id`, `db_id`, `category`, `tag_name`, `single_value` """ # Some times object of db_id might changed in database, when we do CRUD operations, # do update now self.load_details(refresh=True) if not self.db_id or not self.taggable_type: raise KeyError("'db_id' and/or 'taggable_type' not set") t_cls1 = aliased(self.appliance.db['classifications']) t_cls2 = aliased(self.appliance.db['classifications']) t_tgg = aliased(self.appliance.db['taggings']) query = self.appliance.db.session.query(t_cls1.tag_id, t_tgg.taggable_id.label('db_id'), t_cls2.description.label('category'), t_cls1.description.label('tag_name'), t_cls1.single_value)\ .join(t_cls2, t_cls1.parent_id == t_cls2.id)\ .join(t_tgg, t_tgg.tag_id == t_cls1.tag_id)\ .filter(t_tgg.taggable_id == self.db_id)\ .filter(t_tgg.taggable_type == self.taggable_type) tags = [] for tag in query.all(): tags.append( Tag(category=Category(display_name=tag.category, single_value=tag.single_value), display_name=tag.tag_name)) return tags
def test_tags(provider): """Tests tags in provider page Steps: * Run `validate_tags` with `tags` input """ tags = [ Tag(category=Category(display_name='Department', single_value=False), display_name='Engineering'), Tag(category=Category(display_name='Environment', single_value=True), display_name='Test'), Tag(category=Category(display_name='Location', single_value=True), display_name='Paris'), Tag(category=Category(display_name='Service Level', single_value=True), display_name='Gold'), ] provider.validate_tags(tags=tags)
def test_tags(provider): """Tests tags in server page Steps: * Select a server randomly from database * Run `validate_tags` with `tags` input """ tags = [ Tag(category=Category(display_name='Environment', single_value=True), display_name='Test'), Tag(category=Category(display_name='Location', single_value=True), display_name='New York'), Tag(category=Category(display_name='Workload', single_value=False), display_name='Application Servers'), ] servers_db = MiddlewareServer.servers_in_db(provider=provider) assert len(servers_db) > 0, "There is no server(s) available in DB" server = get_random_list(servers_db, 1)[0] server.validate_tags(tags=tags)
def get_tags(self, tag="My Company Tags"): self.load_details(refresh=True) tags = [] # Sample out put from UI, [u'Department: Accounting | Engineering', u'Location: London'] for _tag in mixins.get_tags(tag=tag): if _tag == 'No {} have been assigned'.format(tag): return tags _tag = _tag.split(':', 1) if len(_tag) != 2: raise RuntimeError('Unknown format of tagging in UI [{}]'.format(_tag)) if ' | ' in _tag[1]: for _sub_tag in _tag[1].split(' | '): tags.append(Tag(category=Category(display_name=tag[0], single_value=None), display_name=_sub_tag.strip())) else: tags.append(Tag(category=Category(display_name=_tag[0], single_value=None), display_name=_tag[1].strip())) return tags
def test_tag_crud(category): tag = Tag(name=generate_lowercase_random_string(size=8), display_name=generate_random_string(size=32), category=category) tag.create() with update(tag): tag.display_name = generate_random_string(size=32) tag.delete(cancel=False)
def test_tag_crud(category): tag = Tag(name=fauxfactory.gen_alphanumeric(8).lower(), display_name=fauxfactory.gen_alphanumeric(32), category=category) tag.create() with update(tag): tag.display_name = fauxfactory.gen_alphanumeric(32) tag.delete(cancel=False)
def tag(category): tag = Tag(name=fauxfactory.gen_alpha(8).lower(), display_name=fauxfactory.gen_alphanumeric(length=32), category=category) tag.create() yield tag tag.delete()
def set_random_tag(instance): navigate_to(instance, 'Details') toolbar.select('Policy', 'Edit Tags') # select random tag category cat_selector = AngularSelect("tag_cat") random_cat = random.choice(cat_selector.all_options) cat_selector.select_by_value(random_cat.value) # select random tag tag tag_selector = AngularSelect("tag_add") random_tag = random.choice([op for op in tag_selector.all_options if op.value != "select"]) tag_selector.select_by_value(random_tag.value) # Save tag conig form_buttons.save() return Tag(display_name=random_tag.text, category=random_cat.text)
def set_random_tag(instance): logger.debug("Setting random tag") navigate_to(instance, 'Details') toolbar.select('Policy', 'Edit Tags') # select random tag category cat_selector = AngularSelect("tag_cat") random_cat = random.choice(cat_selector.all_options) logger.debug("Selected category {cat}".format(cat=random_cat)) cat_selector.select_by_value(random_cat.value) # select random tag tag tag_selector = AngularSelect("tag_add") random_tag = random.choice([op for op in tag_selector.all_options if op.value != "select"]) logger.debug("Selected value {tag}".format(tag=random_tag)) tag_selector.select_by_value(random_tag.value) # Save tag conig form_buttons.save() logger.debug("Tag configuration was saved") return Tag(display_name=random_tag.text, category=random_cat.text)
from cfme.middleware.deployment import MiddlewareDeployment from cfme.middleware.domain import MiddlewareDomain from cfme.middleware.server_group import MiddlewareServerGroup from cfme.middleware.messaging import MiddlewareMessaging from random_methods import get_random_object from cfme.utils import testgen from cfme.utils.version import current_version pytestmark = [ pytest.mark.usefixtures('setup_provider'), pytest.mark.uncollectif(lambda: current_version() < '5.7'), ] pytest_generate_tests = testgen.generate([HawkularProvider], scope="function") tags = [ Tag(category=Category(display_name='Environment', single_value=True), display_name='Test'), Tag(category=Category(display_name='Location', single_value=True), display_name='New York'), Tag(category=Category(display_name='Workload', single_value=False), display_name='Application Servers'), ] @pytest.mark.parametrize("objecttype", [ MiddlewareDatasource, MiddlewareDeployment, HawkularProvider, MiddlewareServer, MiddlewareDomain, MiddlewareMessaging, MiddlewareServerGroup ]) def test_object_tags(provider, objecttype): """Tests tags in all taggable pages