def test_positive_remove_hostgroup(self): """Add a hostgroup and remove it by using the location name and hostgroup name @feature: Locations @assert: hostgroup is added to location then removed """ strategy, value = common_locators['all_values_selection'] with Session(self.browser) as session: for host_grp_name in generate_strings_list(): with self.subTest(host_grp_name): loc_name = gen_string('alpha') host_grp = entities.HostGroup(name=host_grp_name).create() self.assertEqual(host_grp.name, host_grp_name) set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_hostgrps']) element = session.nav.wait_until_element( (strategy, value % host_grp_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.hostgroup.delete(host_grp_name) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_hostgrps']) element = session.nav.wait_until_element( (strategy, value % host_grp_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNone(element)
def test_positive_remove_domain(self): """Add a domain to an location and remove it by location name and domain name @feature: Locations @assert: the domain is removed from the location """ strategy, value = common_locators['entity_select'] strategy1, value1 = common_locators['entity_deselect'] with Session(self.browser) as session: for domain_name in generate_strings_list(): with self.subTest(domain_name): loc_name = gen_string('alpha') domain = entities.Domain(name=domain_name).create() self.assertEqual(domain.name, domain_name) set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name, domains=[domain_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_domains']) element = session.nav.wait_until_element( (strategy1, value1 % domain_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, domains=[domain_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_domains']) element = session.nav.wait_until_element( (strategy, value % domain_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_remove_environment(self): """Remove environment by using location name & environment name @feature: Locations @assert: environment is removed from Location """ strategy, value = common_locators['entity_select'] strategy1, value1 = common_locators['entity_deselect'] with Session(self.browser) as session: for env_name in valid_env_names(): with self.subTest(env_name): loc_name = gen_string('alpha') env = entities.Environment(name=env_name).create() self.assertEqual(env.name, env_name) set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name, envs=[env_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_env']) element = session.nav.wait_until_element( (strategy1, value1 % env_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, envs=[env_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_env']) element = session.nav.wait_until_element( (strategy, value % env_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_add_template(self): """Add config template by using location name and config template name. @feature: Locations @assert: config template is added. """ strategy, value = common_locators['all_values_selection'] with Session(self.browser) as session: for template in generate_strings_list(): with self.subTest(template): loc_name = gen_string('alpha') make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) make_templates( session, name=template, template_path=get_data_file(OS_TEMPLATE_DATA_FILE), custom_really=True, template_type='provision', ) self.assertIsNotNone(self.template.search(template)) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_template']) element = session.nav.wait_until_element( (strategy, value % template)) self.assertIsNotNone(element)
def test_positive_remove_compresource(self): """Remove compute resource by using the location name and compute resource name @feature: Locations @assert: compute resource is added then removed """ strategy, value = common_locators['entity_select'] strategy1, value1 = common_locators['entity_deselect'] with Session(self.browser) as session: for resource_name in generate_strings_list(): with self.subTest(resource_name): loc_name = gen_string('alpha') url = LIBVIRT_RESOURCE_URL % settings.server.hostname resource = entities.LibvirtComputeResource( name=resource_name, url=url).create() self.assertEqual(resource.name, resource_name) set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name, resources=[resource_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_resources']) element = self.location.wait_until_element( (strategy1, value1 % resource_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, resources=[resource_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_resources']) element = session.nav.wait_until_element( (strategy, value % resource_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_remove_subnet(self): """Remove subnet by using location name and subnet name @feature: Locations @assert: subnet is added then removed """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] with Session(self.browser) as session: for subnet_name in generate_strings_list(): with self.subTest(subnet_name): loc_name = gen_string("alpha") subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask="255.255.255.0" ).create() self.assertEqual(subnet.name, subnet_name) set_context(session, org=ANY_CONTEXT["org"]) make_loc(session, name=loc_name, subnets=[subnet_name]) self.location.search(loc_name).click() session.nav.click(tab_locators["context.tab_subnets"]) element = session.nav.wait_until_element((strategy1, value1 % subnet_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, subnets=[subnet_name]) self.location.search(loc_name).click() self.location.click(tab_locators["context.tab_subnets"]) element = session.nav.wait_until_element((strategy, value % subnet_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNotNone(element)
def test_remove_medium(self, medium_name): """@test: Remove medium by using location name and medium name @feature: Locations @assert: medium is added then removed """ strategy, value = common_locators['entity_select'] strategy1, value1 = common_locators['entity_deselect'] loc_name = gen_string('alpha') medium = entities.Media( name=medium_name, path_=INSTALL_MEDIUM_URL % gen_string('alpha', 6), os_family='Redhat', ).create() self.assertEqual(medium.name, medium_name) with Session(self.browser) as session: set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name, medias=[medium_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_media']) element = session.nav.wait_until_element( (strategy1, value1 % medium_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, medias=[medium_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_media']) element = session.nav.wait_until_element( (strategy, value % medium_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_remove_computeresource(self, resource_name): """@test: Remove compute resource by using the location name and compute resource name @feature: Locations @assert: compute resource is added then removed """ strategy, value = common_locators['entity_select'] strategy1, value1 = common_locators['entity_deselect'] loc_name = gen_string('alpha') url = (LIBVIRT_RESOURCE_URL % conf.properties['main.server.hostname']) resource = entities.LibvirtComputeResource( name=resource_name, url=url).create() self.assertEqual(resource.name, resource_name) with Session(self.browser) as session: set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name, resources=[resource_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_resources']) element = self.location.wait_until_element( (strategy1, value1 % resource_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, resources=[resource_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_resources']) element = session.nav.wait_until_element( (strategy, value % resource_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_add_subnet(self): """Add a subnet by using location name and subnet name :id: fe70ffba-e594-48d5-b2c5-be93e827cc60 :expectedresults: subnet is added :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for subnet_name in generate_strings_list(): with self.subTest(subnet_name): loc_name = gen_string('alpha') subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask='255.255.255.0', ).create() self.assertEqual(subnet.name, subnet_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_subnets=[subnet_name]) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element( (strategy, value % subnet_name)) self.assertIsNotNone(element)
def test_positive_add_subnet(self): """Add a subnet by using location name and subnet name @feature: Locations @assert: subnet is added """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for subnet_name in generate_strings_list(): with self.subTest(subnet_name): loc_name = gen_string('alpha') subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask='255.255.255.0', ).create() self.assertEqual(subnet.name, subnet_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_subnets=[subnet_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element( (strategy, value % subnet_name)) self.assertIsNotNone(element)
def test_positive_add_template(self): """Add config template by using location name and config template name. :id: 8faf60d1-f4d6-4a58-a484-606a42957ce7 :expectedresults: config template is added. :CaseLevel: Integration """ strategy, value = common_locators['all_values_selection'] with Session(self.browser) as session: for template in generate_strings_list(): with self.subTest(template): loc_name = gen_string('alpha') make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) make_templates( session, name=template, template_path=get_data_file(OS_TEMPLATE_DATA_FILE), custom_really=True, template_type='Provisioning template', ) self.assertIsNotNone(self.template.search(template)) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_template']) element = session.nav.wait_until_element( (strategy, value % template)) self.assertIsNotNone(element)
def test_add_configtemplate_1(self, template): """@test: Add config template by using location name and configtemplate name. @feature: Locations @assert: configtemplate is added. """ strategy, value = common_locators["all_values_selection"] loc_name = gen_string("alpha", 8) temp_type = 'provision' template_path = get_data_file(OS_TEMPLATE_DATA_FILE) with Session(self.browser) as session: make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) make_templates(session, name=template, template_path=template_path, custom_really=True, template_type=temp_type) self.assertIsNotNone(self.template.search(template)) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_template"]).click() element = session.nav.wait_until_element((strategy, value % template)) self.assertIsNotNone(element)
def test_positive_add_user(self): """Create user then add that user by using the location name :id: bf9b3fc2-6193-4edc-aaec-cd7b87f0804c :expectedresults: User is added to location :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: # User names does not accept html values for user_name in generate_strings_list(length=10, exclude_types=['html']): with self.subTest(user_name): loc_name = gen_string('alpha') password = gen_string('alpha') user = entities.User( login=user_name, firstname=user_name, lastname=user_name, password=password, ).create() self.assertEqual(user.login, user_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_users=[user_name]) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_users']) element = session.nav.wait_until_element( (strategy, value % user_name)) self.assertIsNotNone(element)
def test_positive_add_compresource(self): """Add compute resource using the location name and compute resource name :id: 1d24414a-666d-490d-89b9-cd0704684cdd :expectedresults: compute resource is added successfully :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for resource_name in generate_strings_list(): with self.subTest(resource_name): loc_name = gen_string('alpha') url = (LIBVIRT_RESOURCE_URL % settings.compute_resources.libvirt_hostname) resource = entities.LibvirtComputeResource( name=resource_name, url=url).create() self.assertEqual(resource.name, resource_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_resources=[resource_name]) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_resources']) element = session.nav.wait_until_element( (strategy, value % resource_name)) self.assertIsNotNone(element)
def test_positive_remove_user(self): """Create admin users then add user and remove it by using the location name @feature: Locations @assert: The user is added then removed from the location """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] with Session(self.browser) as session: # User names does not accept html values for user_name in generate_strings_list(length=10, exclude_types=["html"]): with self.subTest(user_name): loc_name = gen_string("alpha") user = entities.User( login=user_name, firstname=user_name, lastname=user_name, password=gen_string("alpha") ).create() self.assertEqual(user.login, user_name) set_context(session, org=ANY_CONTEXT["org"]) make_loc(session, name=loc_name, users=[user_name]) self.location.search(loc_name).click() session.nav.click(tab_locators["context.tab_users"]) element = session.nav.wait_until_element((strategy1, value1 % user_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, users=[user_name]) self.location.search(loc_name).click() session.nav.click(tab_locators["context.tab_users"]) element = session.nav.wait_until_element((strategy, value % user_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_remove_medium(self): """Remove medium by using location name and medium name @feature: Locations @assert: medium is added then removed """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] with Session(self.browser) as session: for medium_name in generate_strings_list(): with self.subTest(medium_name): loc_name = gen_string("alpha") medium = entities.Media( name=medium_name, path_=INSTALL_MEDIUM_URL % gen_string("alpha", 6), os_family="Redhat" ).create() self.assertEqual(medium.name, medium_name) set_context(session, org=ANY_CONTEXT["org"]) make_loc(session, name=loc_name, medias=[medium_name]) self.location.search(loc_name).click() session.nav.click(tab_locators["context.tab_media"]) element = session.nav.wait_until_element((strategy1, value1 % medium_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, medias=[medium_name]) self.location.search(loc_name).click() session.nav.click(tab_locators["context.tab_media"]) element = session.nav.wait_until_element((strategy, value % medium_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_add_compresource(self): """Add compute resource using the location name and compute resource name :id: 1d24414a-666d-490d-89b9-cd0704684cdd :expectedresults: compute resource is added successfully :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self) as session: for resource_name in generate_strings_list(): with self.subTest(resource_name): loc_name = gen_string('alpha') url = (LIBVIRT_RESOURCE_URL % settings.compute_resources.libvirt_hostname) resource = entities.LibvirtComputeResource( name=resource_name, url=url).create() self.assertEqual(resource.name, resource_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update( loc_name, new_resources=[resource_name]) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_resources']) element = session.nav.wait_until_element( (strategy, value % resource_name)) self.assertIsNotNone(element)
def test_remove_hostgroup_1(self, host_grp_name): """@test: Add a hostgroup and remove it by using the location name and hostgroup name @feature: Locations @assert: hostgroup is added to location then removed """ strategy, value = common_locators["all_values_selection"] loc_name = gen_string("alpha", 8) host_grp = entities.HostGroup(name=host_grp_name).create_json() self.assertEqual(host_grp['name'], host_grp_name) with Session(self.browser) as session: set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_hostgrps"]).click() element = session.nav.wait_until_element((strategy, value % host_grp_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.hostgroup.delete(host_grp_name, True) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_hostgrps"]).click() element = session.nav.wait_until_element((strategy, value % host_grp_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNone(element)
def test_positive_update_with_all_users_setting_only(self): """Create location and do not add user to it. Check and uncheck 'all users' setting. Verify that for both operation expected location is assigned to user :id: 6596962b-8fd0-4a82-bf54-fa6a31147311 :expectedresults: Location entity is assigned to user after checkbox was enabled and then disabled afterwards :BZ: 1321543 :CaseLevel: Integration """ loc_name = gen_string('alpha') user = entities.User().create() with Session(self) as session: set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name) for value in [True, False]: self.location.search_and_click(loc_name) self.location.click(tab_locators['context.tab_users']) self.location.assign_value( locators['location.all_users'], value) self.location.click(common_locators['submit']) self.user.search_and_click(user.login) self.user.click(tab_locators['tab_loc']) self.assertIsNotNone(self.user.wait_until_element( common_locators['entity_deselect'] % loc_name))
def test_positive_add_org(self): """Add a organization by using the location name :id: 27d56d64-6866-46b6-962d-1ac2a11ae136 :expectedresults: organization is added to location :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self) as session: for org_name in generate_strings_list(): with self.subTest(org_name): loc_name = gen_string('alpha') org = entities.Organization(name=org_name).create() self.assertEqual(org.name, org_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update( loc_name, new_organizations=[org_name]) self.location.search_and_click(loc_name) session.nav.click( tab_locators['context.tab_organizations']) element = session.nav.wait_until_element( (strategy, value % org_name)) self.assertIsNotNone(element)
def test_positive_add_user(self): """Create user then add that user by using the location name :id: bf9b3fc2-6193-4edc-aaec-cd7b87f0804c :expectedresults: User is added to location :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self) as session: # User names does not accept html values for user_name in generate_strings_list( length=10, exclude_types=['html']): with self.subTest(user_name): loc_name = gen_string('alpha') password = gen_string('alpha') user = entities.User( login=user_name, firstname=user_name, lastname=user_name, password=password, ).create() self.assertEqual(user.login, user_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_users=[user_name]) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_users']) element = session.nav.wait_until_element( (strategy, value % user_name)) self.assertIsNotNone(element)
def test_positive_add_subnet(self): """Add a subnet by using location name and subnet name :id: fe70ffba-e594-48d5-b2c5-be93e827cc60 :expectedresults: subnet is added :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self) as session: for subnet_name in generate_strings_list(): with self.subTest(subnet_name): loc_name = gen_string('alpha') subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask='255.255.255.0', ).create() self.assertEqual(subnet.name, subnet_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_subnets=[subnet_name]) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element( (strategy, value % subnet_name)) self.assertIsNotNone(element)
def test_remove_environment_1(self, env_name): """@test: Remove environment by using location name & evironment name @feature: Locations @assert: environment is removed from Location """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) env = entities.Environment(name=env_name).create_json() self.assertEqual(env['name'], env_name) with Session(self.browser) as session: set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name, envs=[env_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_env"]).click() element = session.nav.wait_until_element((strategy1, value1 % env_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, envs=[env_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_env"]).click() element = session.nav.wait_until_element((strategy, value % env_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_add_medium(self): """Add medium by using the location name and medium name :id: 738c5ff1-ef09-466f-aaac-64f194cac78d :expectedresults: medium is added :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self) as session: for medium_name in generate_strings_list(): with self.subTest(medium_name): loc_name = gen_string('alpha') medium = entities.Media( name=medium_name, path_=INSTALL_MEDIUM_URL % gen_string('alpha', 6), os_family='Redhat', ).create() self.assertEqual(medium.name, medium_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_medias=[medium_name]) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_media']) element = session.nav.wait_until_element( (strategy, value % medium_name)) self.assertIsNotNone(element)
def test_remove_domain_1(self, domain_name): """@test: Add a domain to an location and remove it by location name and domain name @feature: Locations @assert: the domain is removed from the location """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) domain = entities.Domain(name=domain_name).create_json() self.assertEqual(domain['name'], domain_name) with Session(self.browser) as session: set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name, domains=[domain_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_domains"]).click() element = session.nav.wait_until_element((strategy1, value1 % domain_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, domains=[domain_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_domains"]).click() element = session.nav.wait_until_element((strategy, value % domain_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_add_template(self): """Add config template by using location name and config template name. :id: 8faf60d1-f4d6-4a58-a484-606a42957ce7 :expectedresults: config template is added. :CaseLevel: Integration """ strategy, value = common_locators['all_values_selection'] with Session(self) as session: for template in generate_strings_list(): with self.subTest(template): loc_name = gen_string('alpha') make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) make_templates( session, name=template, template_path=get_data_file(OS_TEMPLATE_DATA_FILE), custom_really=True, template_type='Provisioning template', ) self.assertIsNotNone(self.template.search(template)) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_template']) element = session.nav.wait_until_element( (strategy, value % template)) self.assertIsNotNone(element)
def test_add_compresource(self): """Add compute resource using the location name and compute resource name @feature: Locations @assert: compute resource is added successfully """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for resource_name in generate_strings_list(): with self.subTest(resource_name): loc_name = gen_string('alpha') url = LIBVIRT_RESOURCE_URL % settings.server.hostname resource = entities.LibvirtComputeResource( name=resource_name, url=url).create() self.assertEqual(resource.name, resource_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_resources=[resource_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_resources']) element = session.nav.wait_until_element( (strategy, value % resource_name)) self.assertIsNotNone(element)
def test_add_subnet_1(self, subnet_name): """@test: Add a subnet by using location name and subnet name @feature: Locations @assert: subnet is added """ strategy, value = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) subnet_network = gen_ipaddr(ip3=True) subnet_mask = "255.255.255.0" subnet = entities.Subnet( name=subnet_name, network=subnet_network, mask=subnet_mask ).create_json() self.assertEqual(subnet['name'], subnet_name) with Session(self.browser) as session: make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_subnets=[subnet_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_subnets"]).click() element = session.nav.wait_until_element((strategy, value % subnet_name)) self.assertIsNotNone(element)
def test_positive_remove_compresource(self): """Remove compute resource by using the location name and compute resource name @feature: Locations @assert: compute resource is added then removed """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] with Session(self.browser) as session: for resource_name in generate_strings_list(): with self.subTest(resource_name): loc_name = gen_string("alpha") url = LIBVIRT_RESOURCE_URL % settings.server.hostname resource = entities.LibvirtComputeResource(name=resource_name, url=url).create() self.assertEqual(resource.name, resource_name) set_context(session, org=ANY_CONTEXT["org"]) make_loc(session, name=loc_name, resources=[resource_name]) self.location.search(loc_name).click() session.nav.click(tab_locators["context.tab_resources"]) element = self.location.wait_until_element((strategy1, value1 % resource_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, resources=[resource_name]) self.location.search(loc_name).click() session.nav.click(tab_locators["context.tab_resources"]) element = session.nav.wait_until_element((strategy, value % resource_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNotNone(element)
def test_add_user_1(self, user_name): """@test: Create user then add user by using the location name @feature: Locations @assert: User is added to location """ strategy, value = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) password = gen_string("alpha", 8) user = entities.User( login=user_name, firstname=user_name, lastname=user_name, password=password).create_json() self.assertEqual(user['login'], user_name) with Session(self.browser) as session: make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_users=[user_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_users"]).click() element = session.nav.wait_until_element((strategy, value % user_name)) self.assertIsNotNone(element)
def test_add_computeresource_1(self, resource_name): """@test: Add compute resource using the location name and computeresource name @feature: Locations @assert: computeresource is added """ strategy, value = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) libvirt_url = "qemu+tcp://%s:16509/system" url = (libvirt_url % conf.properties['main.server.hostname']) resource = entities.ComputeResource( name=resource_name, provider='Libvirt', url=url ).create_json() self.assertEqual(resource['name'], resource_name) with Session(self.browser) as session: make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_resources=[resource_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_resources"]).click() element = session.nav.wait_until_element((strategy, value % resource_name)) self.assertIsNotNone(element)
def test_add_medium_1(self, medium_name): """@test: Add medium by using the location name and medium name @feature: Locations @assert: medium is added """ strategy, value = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) path = INSTALL_MEDIUM_URL % gen_string("alpha", 6) medium = entities.Media( name=medium_name, media_path=path, os_family='Redhat', ).create_json() self.assertEqual(medium['name'], medium_name) with Session(self.browser) as session: make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_medias=[medium_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_media"]).click() element = session.nav.wait_until_element((strategy, value % medium_name)) self.assertIsNotNone(element)
def test_positive_add_medium(self): """Add medium by using the location name and medium name :id: 738c5ff1-ef09-466f-aaac-64f194cac78d :expectedresults: medium is added :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for medium_name in generate_strings_list(): with self.subTest(medium_name): loc_name = gen_string('alpha') medium = entities.Media( name=medium_name, path_=INSTALL_MEDIUM_URL % gen_string('alpha', 6), os_family='Redhat', ).create() self.assertEqual(medium.name, medium_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_medias=[medium_name]) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_media']) element = session.nav.wait_until_element( (strategy, value % medium_name)) self.assertIsNotNone(element)
def test_remove_user(self, user_name): """@test: Create admin users then add user and remove it by using the location name @feature: Locations @assert: The user is added then removed from the location """ strategy, value = common_locators['entity_select'] strategy1, value1 = common_locators['entity_deselect'] loc_name = gen_string('alpha') user = entities.User( login=user_name, firstname=user_name, lastname=user_name, password=gen_string('alpha'), ).create() self.assertEqual(user.login, user_name) with Session(self.browser) as session: set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name, users=[user_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_users']) element = session.nav.wait_until_element( (strategy1, value1 % user_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, users=[user_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_users']) element = session.nav.wait_until_element( (strategy, value % user_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_add_medium(self): """Add medium by using the location name and medium name @feature: Locations @assert: medium is added """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for medium_name in generate_strings_list(): with self.subTest(medium_name): loc_name = gen_string('alpha') medium = entities.Media( name=medium_name, path_=INSTALL_MEDIUM_URL % gen_string('alpha', 6), os_family='Redhat', ).create() self.assertEqual(medium.name, medium_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_medias=[medium_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_media']) element = session.nav.wait_until_element( (strategy, value % medium_name)) self.assertIsNotNone(element)
def test_positive_add_org(self): """Add a organization by using the location name :id: 27d56d64-6866-46b6-962d-1ac2a11ae136 :expectedresults: organization is added to location :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for org_name in generate_strings_list(): with self.subTest(org_name): loc_name = gen_string('alpha') org = entities.Organization(name=org_name).create() self.assertEqual(org.name, org_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_organizations=[org_name]) self.location.search_and_click(loc_name) session.nav.click( tab_locators['context.tab_organizations']) element = session.nav.wait_until_element( (strategy, value % org_name)) self.assertIsNotNone(element)
def test_positive_add_user(self): """Create user then add that user by using the location name @feature: Locations @assert: User is added to location """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: # User names does not accept html values for user_name in generate_strings_list( length=10, remove_str='html'): with self.subTest(user_name): loc_name = gen_string('alpha') password = gen_string('alpha') user = entities.User( login=user_name, firstname=user_name, lastname=user_name, password=password, ).create() self.assertEqual(user.login, user_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_users=[user_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_users']) element = session.nav.wait_until_element( (strategy, value % user_name)) self.assertIsNotNone(element)
def test_add_compresource(self): """Add compute resource using the location name and compute resource name @feature: Locations @assert: compute resource is added successfully """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for resource_name in generate_strings_list(): with self.subTest(resource_name): loc_name = gen_string('alpha') url = LIBVIRT_RESOURCE_URL % settings.server.hostname resource = entities.LibvirtComputeResource( name=resource_name, url=url).create() self.assertEqual(resource.name, resource_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update( loc_name, new_resources=[resource_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_resources']) element = session.nav.wait_until_element( (strategy, value % resource_name)) self.assertIsNotNone(element)
def test_remove_medium_1(self, medium_name): """@test: Remove medium by using location name and medium name @feature: Locations @assert: medium is added then removed """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) path = INSTALL_MEDIUM_URL % gen_string("alpha", 6) medium = entities.Media( name=medium_name, media_path=path, os_family='Redhat', ).create() self.assertEqual(medium['name'], medium_name) with Session(self.browser) as session: make_loc(session, name=loc_name, medias=[medium_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_media"]).click() element = session.nav.wait_until_element( (strategy1, value1 % medium_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, medias=[medium_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_media"]).click() element = session.nav.wait_until_element( (strategy, value % medium_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_remove_hostgroup_1(self, host_grp_name): """@test: Add a hostgroup and remove it by using the location name and hostgroup name @feature: Locations @assert: hostgroup is added to location then removed """ strategy, value = common_locators["all_values_selection"] loc_name = gen_string("alpha", 8) host_grp = entities.HostGroup(name=host_grp_name).create() self.assertEqual(host_grp['name'], host_grp_name) with Session(self.browser) as session: make_loc(session, name=loc_name) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_hostgrps"]).click() element = session.nav.wait_until_element( (strategy, value % host_grp_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.hostgroup.delete(host_grp_name, True) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_hostgrps"]).click() element = session.nav.wait_until_element( (strategy, value % host_grp_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNone(element)
def test_remove_computeresource_1(self, resource_name): """@test: Remove computeresource by using the location name and computeresource name @feature: Locations @assert: computeresource is added then removed """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) libvirt_url = "qemu+tcp://%s:16509/system" url = (libvirt_url % conf.properties['main.server.hostname']) resource = entities.ComputeResource(name=resource_name, provider='Libvirt', url=url).create() self.assertEqual(resource['name'], resource_name) with Session(self.browser) as session: make_loc(session, name=loc_name, resources=[resource_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_resources"]).click() ele = self.location.wait_until_element( (strategy1, value1 % resource_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(ele) self.location.update(loc_name, resources=[resource_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_resources"]).click() element = session.nav.wait_until_element( (strategy, value % resource_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_remove_domain_1(self, domain_name): """@test: Add a domain to an location and remove it by location name and domain name @feature: Locations @assert: the domain is removed from the location """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) domain = entities.Domain(name=domain_name).create() self.assertEqual(domain['name'], domain_name) with Session(self.browser) as session: make_loc(session, name=loc_name, domains=[domain_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_domains"]).click() element = session.nav.wait_until_element( (strategy1, value1 % domain_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, domains=[domain_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_domains"]).click() element = session.nav.wait_until_element( (strategy, value % domain_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_remove_user_1(self, user_name): """@test: Create admin users then add user and remove it by using the location name @feature: Locations @assert: The user is added then removed from the location """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) password = gen_string("alpha", 8) user = entities.User(login=user_name, firstname=user_name, lastname=user_name, password=password).create() self.assertEqual(user['login'], user_name) with Session(self.browser) as session: make_loc(session, name=loc_name, users=[user_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_users"]).click() element = session.nav.wait_until_element( (strategy1, value1 % user_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, users=[user_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_users"]).click() element = session.nav.wait_until_element( (strategy, value % user_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_remove_environment_1(self, env_name): """@test: Remove environment by using location name & evironment name @feature: Locations @assert: environment is removed from Location """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) env = entities.Environment(name=env_name).create() self.assertEqual(env['name'], env_name) with Session(self.browser) as session: make_loc(session, name=loc_name, envs=[env_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_env"]).click() element = session.nav.wait_until_element( (strategy1, value1 % env_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, envs=[env_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_env"]).click() element = session.nav.wait_until_element( (strategy, value % env_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_remove_subnet_1(self, subnet_name): """@test: Remove subnet by using location name and subnet name @feature: Locations @assert: subnet is added then removed """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) subnet_network = gen_ipaddr(ip3=True) subnet_mask = "255.255.255.0" subnet = entities.Subnet(name=subnet_name, network=subnet_network, mask=subnet_mask).create() self.assertEqual(subnet['name'], subnet_name) with Session(self.browser) as session: make_loc(session, name=loc_name, subnets=[subnet_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_subnets"]).click() element = session.nav.wait_until_element( (strategy1, value1 % subnet_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, subnets=[subnet_name]) self.location.search(loc_name).click() self.location.wait_until_element( tab_locators["context.tab_subnets"]).click() element = session.nav.wait_until_element( (strategy, value % subnet_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_add_configtemplate_1(self, template): """@test: Add config template by using location name and configtemplate name. @feature: Locations @assert: configtemplate is added. """ strategy, value = common_locators["all_values_selection"] loc_name = gen_string("alpha", 8) temp_type = 'provision' template_path = get_data_file(OS_TEMPLATE_DATA_FILE) with Session(self.browser) as session: make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) make_templates(session, name=template, template_path=template_path, custom_really=True, template_type=temp_type) self.assertIsNotNone(self.template.search(template)) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_template"]).click() element = session.nav.wait_until_element( (strategy, value % template)) self.assertIsNotNone(element)
def test_add_user_1(self, user_name): """@test: Create user then add user by using the location name @feature: Locations @assert: User is added to location """ strategy, value = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) password = gen_string("alpha", 8) user = entities.User(login=user_name, firstname=user_name, lastname=user_name, password=password).create() self.assertEqual(user['login'], user_name) with Session(self.browser) as session: make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_users=[user_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_users"]).click() element = session.nav.wait_until_element( (strategy, value % user_name)) self.assertIsNotNone(element)
def test_search_key_1(self, loc_name): """@test: Create location and search/find it @feature: Locations @assert: location can be found """ with Session(self.browser) as session: make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name))
def test_positive_add_foreman_role(self): """Associate foreman roles to User Group. [belonging to external AD User Group.] @id: c11fbf85-e144-4576-99e3-1ba111479f0f @Steps: 1. Create an UserGroup. 2. Assign some foreman roles to UserGroup. 3. Create and associate an External AD UserGroup. @Assert: Whether a User belonging to User Group is able to access foreman entities as per roles. @CaseLevel: Integration """ self.check_external_user() strategy, value = locators['login.loggedin'] foreman_role = gen_string('alpha') location_name = gen_string('alpha') with Session(self.browser) as session: make_role(session, name=foreman_role) self.role.update( foreman_role, add_permission=True, permission_list=PERMISSIONS['Location'], resource_type='Location', ) make_usergroup( session, name=self.usergroup_name, roles=[foreman_role], ext_usergrp='foobargroup', ext_authsourceid="LDAP-" + self.ldap_server_name, ) self.assertIsNotNone(self.usergroup.search(self.usergroup_name)) set_context(session, org=ANY_CONTEXT['org']) self.user.update( username=self.ldap_user_name, authorized_by='LDAP-' + self.ldap_server_name, new_password=self.ldap_user_passwd, password_confirmation=self.ldap_user_passwd, ) with Session( self.browser, self.ldap_user_name, self.ldap_user_passwd, ) as session: self.assertIsNotNone( self.login.wait_until_element( (strategy, value % self.ldap_user_name))) make_loc(session, name=location_name) self.assertIsNotNone(self.location.search(location_name))
def test_positive_create_1(self, loc_name): """@test: Create Location with valid name only @feature: Locations @assert: Location is created, label is auto-generated """ with Session(self.browser) as session: make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name))
def test_positive_create_with_name(self): """Create Location with valid name only @feature: Locations @assert: Location is created, label is auto-generated """ with Session(self.browser) as session: for loc_name in generate_strings_list(): with self.subTest(loc_name): make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name))
def test_positive_create_with_name(self): """Create Location with valid name only @id: 92b23082-09e4-49e1-92e1-d6d89d5180ac @assert: Location is created, label is auto-generated """ with Session(self.browser) as session: for loc_name in generate_strings_list(): with self.subTest(loc_name): make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name))
def test_positive_create_with_name(self): """Create Location with valid name only :id: 92b23082-09e4-49e1-92e1-d6d89d5180ac :expectedresults: Location is created, label is auto-generated :CaseImportance: Critical """ with Session(self) as session: for loc_name in generate_strings_list(): with self.subTest(loc_name): make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name))
def test_negative_create_with_invalid_names(self): """Create location with invalid name @id: 85f05458-b86c-4d94-a412-ea03412c4588 @assert: location is not created """ with Session(self.browser) as session: for loc_name in invalid_values_list(interface='ui'): with self.subTest(loc_name): make_loc(session, name=loc_name) error = session.nav.wait_until_element( common_locators['name_haserror']) self.assertIsNotNone(error)