Skip to content

Commit

Permalink
[6.14.z] - remove the all nailgun imports from UI folder (#14431)
Browse files Browse the repository at this point in the history
remove the all nailgun imports from UI folder
  • Loading branch information
omkarkhatavkar authored Jun 14, 2024
1 parent 93c2e1b commit 14acf06
Show file tree
Hide file tree
Showing 22 changed files with 190 additions and 184 deletions.
5 changes: 2 additions & 3 deletions tests/foreman/ui/test_architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
"""

from fauxfactory import gen_string
from nailgun import entities
import pytest


@pytest.mark.tier2
@pytest.mark.upgrade
def test_positive_end_to_end(session):
def test_positive_end_to_end(session, target_sat):
"""Perform end to end testing for architecture component
:id: eef14b29-9f5a-41aa-805e-73398ed2b112
Expand All @@ -30,7 +29,7 @@ def test_positive_end_to_end(session):
"""
name = gen_string('alpha')
new_name = gen_string('alpha')
os = entities.OperatingSystem().create()
os = target_sat.api.OperatingSystem().create()
os_name = f'{os.name} {os.major}'
with session:
# Create new architecture with assigned operating system
Expand Down
21 changes: 10 additions & 11 deletions tests/foreman/ui/test_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,22 @@
"""

from fauxfactory import gen_string
from nailgun import entities
import pytest

from robottelo.constants import ENVIRONMENT


@pytest.fixture(scope='module')
def module_org():
return entities.Organization().create()
def module_org(module_target_sat):
return module_target_sat.api.Organization().create()


pytestmark = [pytest.mark.run_in_one_thread]


@pytest.mark.tier2
@pytest.mark.upgrade
def test_positive_create_event(session, module_org, module_location):
def test_positive_create_event(session, module_org, module_location, module_target_sat):
"""When new host is created, corresponding audit entry appear in the application
:id: d0595705-f4b2-4f06-888b-ee93edd4acf8
Expand All @@ -40,7 +39,7 @@ def test_positive_create_event(session, module_org, module_location):
:BZ: 1730360
"""
host = entities.Host(organization=module_org, location=module_location).create()
host = module_target_sat.api.Host(organization=module_org, location=module_location).create()
with session:
session.organization.select(org_name=module_org.name)
session.location.select(loc_name=module_location.name)
Expand Down Expand Up @@ -104,7 +103,7 @@ def test_positive_audit_comment(session, module_org):


@pytest.mark.tier2
def test_positive_update_event(session, module_org):
def test_positive_update_event(session, module_org, module_target_sat):
"""When existing content view is updated, corresponding audit entry appear
in the application
Expand All @@ -120,7 +119,7 @@ def test_positive_update_event(session, module_org):
"""
name = gen_string('alpha')
new_name = gen_string('alpha')
cv = entities.ContentView(name=name, organization=module_org).create()
cv = module_target_sat.api.ContentView(name=name, organization=module_org).create()
cv.name = new_name
cv.update(['name'])
with session:
Expand All @@ -136,7 +135,7 @@ def test_positive_update_event(session, module_org):


@pytest.mark.tier2
def test_positive_delete_event(session, module_org):
def test_positive_delete_event(session, module_org, module_target_sat):
"""When existing architecture is deleted, corresponding audit entry appear
in the application
Expand All @@ -148,7 +147,7 @@ def test_positive_delete_event(session, module_org):
:CaseImportance: Medium
"""
architecture = entities.Architecture().create()
architecture = module_target_sat.api.Architecture().create()
architecture.delete()
with session:
values = session.audit.search('type=architecture and action=destroy')
Expand All @@ -161,7 +160,7 @@ def test_positive_delete_event(session, module_org):


@pytest.mark.tier2
def test_positive_add_event(session, module_org):
def test_positive_add_event(session, module_org, module_target_sat):
"""When content view is published and proper lifecycle environment added to it,
corresponding audit entry appear in the application
Expand All @@ -173,7 +172,7 @@ def test_positive_add_event(session, module_org):
:CaseImportance: Medium
"""
cv = entities.ContentView(organization=module_org).create()
cv = module_target_sat.api.ContentView(organization=module_org).create()
cv.publish()
with session:
values = session.audit.search(
Expand Down
15 changes: 9 additions & 6 deletions tests/foreman/ui/test_computeprofiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
"""

from fauxfactory import gen_string
from nailgun import entities
import pytest


@pytest.mark.e2e
@pytest.mark.tier2
@pytest.mark.upgrade
def test_positive_end_to_end(session, module_location, module_org):
def test_positive_end_to_end(session, module_location, module_org, module_target_sat):
"""Perform end to end testing for compute profile component
:id: 5445fc7e-7b3f-472f-8a94-93f89aca6c22
Expand All @@ -31,13 +30,13 @@ def test_positive_end_to_end(session, module_location, module_org):
"""
name = gen_string('alpha')
new_name = gen_string('alpha')
compute_resource = entities.LibvirtComputeResource(
compute_resource = module_target_sat.api.LibvirtComputeResource(
location=[module_location], organization=[module_org], url='qemu+ssh://root@test/system'
).create()
with session:
session.computeprofile.create({'name': name})

assert entities.ComputeProfile().search(query={'search': f'name={name}'}), (
assert module_target_sat.api.ComputeProfile().search(query={'search': f'name={name}'}), (
f'Compute profile {name} expected to exist, but is not included in the search '
'results'
)
Expand All @@ -46,12 +45,16 @@ def test_positive_end_to_end(session, module_location, module_org):
resource['Compute Resource'] for resource in compute_resource_list
]
session.computeprofile.rename(name, {'name': new_name})
assert entities.ComputeProfile().search(query={'search': f'name={new_name}'}), (
assert module_target_sat.api.ComputeProfile().search(
query={'search': f'name={new_name}'}
), (
f'Compute profile {new_name} expected to exist, but is not included in the search '
'results'
)
session.computeprofile.delete(new_name)
assert not entities.ComputeProfile().search(query={'search': f'name={new_name}'}), (
assert not module_target_sat.api.ComputeProfile().search(
query={'search': f'name={new_name}'}
), (
f'Compute profile {new_name} expected to be deleted, but is included in the search '
'results'
)
41 changes: 23 additions & 18 deletions tests/foreman/ui/test_computeresource.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"""

from nailgun import entities
import pytest
from wait_for import wait_for

Expand Down Expand Up @@ -86,7 +85,9 @@ def test_positive_end_to_end(session, rhev_data, module_target_sat):
assert not session.computeresource.search(name)
assert session.computeresource.search(new_name)[0]['Name'] == new_name
session.computeresource.delete(new_name)
assert not entities.AbstractComputeResource().search(query={'search': f'name={new_name}'})
assert not module_target_sat.api.AbstractComputeResource().search(
query={'search': f'name={new_name}'}
)


@pytest.mark.tier2
Expand Down Expand Up @@ -226,7 +227,7 @@ def test_positive_resource_vm_power_management(session, rhev_data):


@pytest.mark.tier3
def test_positive_VM_import(session, module_org, module_location, rhev_data):
def test_positive_VM_import(session, module_org, module_location, rhev_data, module_target_sat):
"""Import an existing VM as a Host
:id: 47aea4b7-9258-4863-8966-9a0bc9e94116
Expand All @@ -240,34 +241,38 @@ def test_positive_VM_import(session, module_org, module_location, rhev_data):
:BZ: 1636067
"""
# create entities for hostgroup
default_loc_id = entities.Location().search(query={'search': f'name="{DEFAULT_LOC}"'})[0].id
entities.SmartProxy(id=1, location=[default_loc_id, module_location.id]).update()
domain = entities.Domain(organization=[module_org.id], location=[module_location]).create()
subnet = entities.Subnet(
default_loc_id = (
module_target_sat.api.Location().search(query={'search': f'name="{DEFAULT_LOC}"'})[0].id
)
module_target_sat.api.SmartProxy(id=1, location=[default_loc_id, module_location.id]).update()
domain = module_target_sat.api.Domain(
organization=[module_org.id], location=[module_location]
).create()
subnet = module_target_sat.api.Subnet(
organization=[module_org.id], location=[module_location], domain=[domain]
).create()
architecture = entities.Architecture().create()
ptable = entities.PartitionTable(
architecture = module_target_sat.api.Architecture().create()
ptable = module_target_sat.api.PartitionTable(
organization=[module_org.id], location=[module_location]
).create()
operatingsystem = entities.OperatingSystem(
operatingsystem = module_target_sat.api.OperatingSystem(
architecture=[architecture], ptable=[ptable]
).create()
medium = entities.Media(
medium = module_target_sat.api.Media(
organization=[module_org.id], location=[module_location], operatingsystem=[operatingsystem]
).create()
le = (
entities.LifecycleEnvironment(name="Library", organization=module_org.id)
module_target_sat.api.LifecycleEnvironment(name="Library", organization=module_org.id)
.search()[0]
.read()
.id
)
cv = entities.ContentView(organization=module_org).create()
cv = module_target_sat.api.ContentView(organization=module_org).create()
cv.publish()

# create hostgroup
hostgroup_name = gen_string('alpha')
entities.HostGroup(
module_target_sat.api.HostGroup(
name=hostgroup_name,
architecture=architecture,
domain=domain,
Expand Down Expand Up @@ -302,14 +307,14 @@ def test_positive_VM_import(session, module_org, module_location, rhev_data):
)
assert session.host.search(rhev_data['vm_name']) is not None
# disassociate the host so the corresponding VM doesn't get removed from the CR on host delete
entities.Host().search(query={'search': 'name~{}'.format(rhev_data['vm_name'])})[
module_target_sat.api.Host().search(query={'search': 'name~{}'.format(rhev_data['vm_name'])})[
0
].disassociate()
entities.Host(name=rhev_data['vm_name']).search()[0].delete()
module_target_sat.api.Host(name=rhev_data['vm_name']).search()[0].delete()


@pytest.mark.tier3
def test_positive_update_organization(session, rhev_data, module_location):
def test_positive_update_organization(session, rhev_data, module_location, module_target_sat):
"""Update a rhev Compute Resource organization
:id: f6656c8e-70a3-40e5-8dda-2154f2eeb042
Expand All @@ -334,7 +339,7 @@ def test_positive_update_organization(session, rhev_data, module_location):
:expectedresults: The rhev Compute Resource is updated
"""
name = gen_string('alpha')
new_organization = entities.Organization().create()
new_organization = module_target_sat.api.Organization().create()
with session:
session.computeresource.create(
{
Expand Down
9 changes: 4 additions & 5 deletions tests/foreman/ui/test_computeresource_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"""

from fauxfactory import gen_string
from nailgun import entities
import pytest

from robottelo.config import settings
Expand Down Expand Up @@ -46,7 +45,7 @@ def module_ec2_settings():
@pytest.mark.skip_if_not_set('http_proxy')
@pytest.mark.skip_if_open("BZ:2032530")
def test_positive_default_end_to_end_with_custom_profile(
session, module_org, module_location, module_ec2_settings
session, module_org, module_location, module_ec2_settings, module_target_sat
):
"""Create EC2 compute resource with default properties and apply it's basic functionality.
Expand All @@ -69,9 +68,9 @@ def test_positive_default_end_to_end_with_custom_profile(
cr_name = gen_string('alpha')
new_cr_name = gen_string('alpha')
cr_description = gen_string('alpha')
new_org = entities.Organization().create()
new_loc = entities.Location().create()
http_proxy = entities.HTTPProxy(
new_org = module_target_sat.api.Organization().create()
new_loc = module_target_sat.api.Location().create()
http_proxy = module_target_sat.api.HTTPProxy(
name=gen_string('alpha', 15),
url=settings.http_proxy.auth_proxy_url,
username=settings.http_proxy.username,
Expand Down
9 changes: 4 additions & 5 deletions tests/foreman/ui/test_computeresource_vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from math import floor, log10
from random import choice

from nailgun import entities
import pytest
from wait_for import TimedOutError, wait_for
from wrapanapi.systems.virtualcenter import vim
Expand Down Expand Up @@ -82,8 +81,8 @@ def get_vmware_datastore_summary_string(vmware, vmwareclient):

@pytest.mark.tier1
@pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True)
def test_positive_end_to_end(session, module_org, module_location, vmware):
"""Perform end to end testing for compute resource VMware component.
def test_positive_end_to_end(session, module_org, module_location, vmware, module_target_sat):
"""Perform end-to-end testing for compute resource VMware component.
:id: 47fc9e77-5b22-46b4-a76c-3217434fde2f
Expand All @@ -95,8 +94,8 @@ def test_positive_end_to_end(session, module_org, module_location, vmware):
display_type = choice(('VNC', 'VMRC'))
vnc_console_passwords = choice((False, True))
enable_caching = choice((False, True))
new_org = entities.Organization().create()
new_loc = entities.Location().create()
new_org = module_target_sat.api.Organization().create()
new_loc = module_target_sat.api.Location().create()
with session:
session.computeresource.create(
{
Expand Down
13 changes: 6 additions & 7 deletions tests/foreman/ui/test_containerimagetag.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"""

from nailgun import entities
import pytest

from robottelo.constants import (
Expand All @@ -25,18 +24,18 @@


@pytest.fixture(scope="module")
def module_org():
return entities.Organization().create()
def module_org(module_target_sat):
return module_target_sat.api.Organization().create()


@pytest.fixture(scope="module")
def module_product(module_org):
return entities.Product(organization=module_org).create()
def module_product(module_org, module_target_sat):
return module_target_sat.api.Product(organization=module_org).create()


@pytest.fixture(scope="module")
def module_repository(module_product):
repo = entities.Repository(
def module_repository(module_product, module_target_sat):
repo = module_target_sat.api.Repository(
content_type=REPO_TYPE['docker'],
docker_upstream_name=CONTAINER_UPSTREAM_NAME,
product=module_product,
Expand Down
7 changes: 4 additions & 3 deletions tests/foreman/ui/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"""

from fauxfactory import gen_string
from nailgun import entities
import pytest

from robottelo.utils.datafactory import valid_domain_names
Expand Down Expand Up @@ -114,7 +113,9 @@ def test_positive_remove_parameter(session, valid_domain_name):
@pytest.mark.e2e
@pytest.mark.tier2
@pytest.mark.upgrade
def test_positive_end_to_end(session, module_org, module_location, valid_domain_name):
def test_positive_end_to_end(
session, module_org, module_location, valid_domain_name, module_target_sat
):
"""Perform end to end testing for domain component
:id: ce90fd87-3e63-4298-a771-38f4aacce091
Expand Down Expand Up @@ -149,4 +150,4 @@ def test_positive_end_to_end(session, module_org, module_location, valid_domain_
assert session.domain.search(new_name)[0]['Description'] == new_name
# Delete domain
session.domain.delete(new_name)
assert not entities.Domain().search(query={'search': f'name={new_name}'})
assert not module_target_sat.api.Domain().search(query={'search': f'name={new_name}'})
Loading

0 comments on commit 14acf06

Please sign in to comment.