Skip to content

Commit

Permalink
fixture support for virt-who config ui : data_form deploy_type virtwh…
Browse files Browse the repository at this point in the history
…o_config
  • Loading branch information
yanpliu authored and JacobCallahan committed Oct 10, 2023
1 parent 29fc81a commit a1dade8
Show file tree
Hide file tree
Showing 10 changed files with 457 additions and 845 deletions.
346 changes: 157 additions & 189 deletions tests/foreman/virtwho/ui/test_esx.py

Large diffs are not rendered by default.

289 changes: 119 additions & 170 deletions tests/foreman/virtwho/ui/test_esx_sca.py

Large diffs are not rendered by default.

74 changes: 20 additions & 54 deletions tests/foreman/virtwho/ui/test_hyperv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,23 @@
:Upstream: No
"""
from fauxfactory import gen_string
import pytest

from robottelo.config import settings
from robottelo.utils.virtwho import (
deploy_configure_by_command,
deploy_configure_by_script,
get_configure_command,
get_configure_file,
get_configure_id,
get_configure_option,
)


@pytest.fixture()
def form_data():
form = {
'debug': True,
'interval': 'Every hour',
'hypervisor_id': 'hostname',
'hypervisor_type': settings.virtwho.hyperv.hypervisor_type,
'hypervisor_content.server': settings.virtwho.hyperv.hypervisor_server,
'hypervisor_content.username': settings.virtwho.hyperv.hypervisor_username,
'hypervisor_content.password': settings.virtwho.hyperv.hypervisor_password,
}
return form


@pytest.fixture()
def virtwho_config(form_data, target_sat, session):
name = gen_string('alpha')
form_data['name'] = name
with session:
session.virtwho_configure.create(form_data)
yield virtwho_config
session.virtwho_configure.delete(name)
assert not session.virtwho_configure.search(name)


class TestVirtwhoConfigforHyperv:
@pytest.mark.tier2
@pytest.mark.parametrize('deploy_type', ['id', 'script'])
@pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True)
def test_positive_deploy_configure_by_id_script(
self, default_org, virtwho_config, session, form_data, deploy_type
self, default_org, org_session, form_data_ui, deploy_type_ui
):
"""Verify configure created and deployed with id.
Expand All @@ -76,37 +49,30 @@ def test_positive_deploy_configure_by_id_script(
:CaseImportance: High
"""
name = form_data['name']
values = session.virtwho_configure.read(name)
if deploy_type == "id":
command = values['deploy']['command']
hypervisor_name, guest_name = deploy_configure_by_command(
command, form_data['hypervisor_type'], debug=True, org=default_org.label
)
elif deploy_type == "script":
script = values['deploy']['script']
hypervisor_name, guest_name = deploy_configure_by_script(
script, form_data['hypervisor_type'], debug=True, org=default_org.label
)
assert session.virtwho_configure.search(name)[0]['Status'] == 'ok'
hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name']
hypervisor_name, guest_name = deploy_type_ui
assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok'
hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name']
vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL'
vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED'
assert (
session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status']
org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][
'status'
]
== 'Unsubscribed hypervisor'
)
session.contenthost.add_subscription(hypervisor_display_name, vdc_physical)
assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green'
org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical)
assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green'
assert (
session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status']
org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status']
== 'Unentitled'
)
session.contenthost.add_subscription(guest_name, vdc_virtual)
assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green'
org_session.contenthost.add_subscription(guest_name, vdc_virtual)
assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green'

@pytest.mark.tier2
def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data):
def test_positive_hypervisor_id_option(
self, default_org, virtwho_config_ui, org_session, form_data_ui
):
"""Verify Hypervisor ID dropdown options.
:id: f2efc018-d57e-4dc5-895e-53af320237de
Expand All @@ -119,16 +85,16 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio
:CaseImportance: Medium
"""
name = form_data['name']
name = form_data_ui['name']
config_id = get_configure_id(name)
config_command = get_configure_command(config_id, default_org.name)
config_file = get_configure_file(config_id)
values = ['uuid', 'hostname']
for value in values:
session.virtwho_configure.edit(name, {'hypervisor_id': value})
results = session.virtwho_configure.read(name)
org_session.virtwho_configure.edit(name, {'hypervisor_id': value})
results = org_session.virtwho_configure.read(name)
assert results['overview']['hypervisor_id'] == value
deploy_configure_by_command(
config_command, form_data['hypervisor_type'], org=default_org.label
config_command, form_data_ui['hypervisor_type'], org=default_org.label
)
assert get_configure_option('hypervisor_id', config_file) == value
62 changes: 8 additions & 54 deletions tests/foreman/virtwho/ui/test_hyperv_sca.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,22 @@
:Upstream: No
"""
from fauxfactory import gen_string
import pytest

from robottelo.config import settings
from robottelo.utils.virtwho import (
deploy_configure_by_command,
deploy_configure_by_script,
get_configure_command,
get_configure_file,
get_configure_id,
get_configure_option,
)


@pytest.fixture()
def form_data():
form = {
'debug': True,
'interval': 'Every hour',
'hypervisor_id': 'hostname',
'hypervisor_type': settings.virtwho.hyperv.hypervisor_type,
'hypervisor_content.server': settings.virtwho.hyperv.hypervisor_server,
'hypervisor_content.username': settings.virtwho.hyperv.hypervisor_username,
'hypervisor_content.password': settings.virtwho.hyperv.hypervisor_password,
}
return form


@pytest.fixture()
def virtwho_config(form_data, target_sat, session_sca):
name = gen_string('alpha')
form_data['name'] = name
with session_sca:
session_sca.virtwho_configure.create(form_data)
yield virtwho_config
session_sca.virtwho_configure.delete(name)
assert not session_sca.virtwho_configure.search(name)


class TestVirtwhoConfigforHyperv:
@pytest.mark.tier2
@pytest.mark.parametrize('deploy_type', ['id', 'script'])
@pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True)
def test_positive_deploy_configure_by_id_script(
self, module_sca_manifest_org, virtwho_config, session_sca, form_data, deploy_type
self, module_sca_manifest_org, org_session, form_data_ui, deploy_type_ui
):
"""Verify configure created and deployed with id.
Expand All @@ -74,29 +46,11 @@ def test_positive_deploy_configure_by_id_script(
:CaseImportance: High
"""
name = form_data['name']
values = session_sca.virtwho_configure.read(name)
if deploy_type == "id":
command = values['deploy']['command']
deploy_configure_by_command(
command,
form_data['hypervisor_type'],
debug=True,
org=module_sca_manifest_org.label,
)
elif deploy_type == "script":
script = values['deploy']['script']
deploy_configure_by_script(
script,
form_data['hypervisor_type'],
debug=True,
org=module_sca_manifest_org.label,
)
assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok'
assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok'

@pytest.mark.tier2
def test_positive_hypervisor_id_option(
self, module_sca_manifest_org, virtwho_config, session_sca, form_data
self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui
):
"""Verify Hypervisor ID dropdown options.
Expand All @@ -110,16 +64,16 @@ def test_positive_hypervisor_id_option(
:CaseImportance: Medium
"""
name = form_data['name']
name = form_data_ui['name']
config_id = get_configure_id(name)
config_command = get_configure_command(config_id, module_sca_manifest_org.name)
config_file = get_configure_file(config_id)
values = ['uuid', 'hostname']
for value in values:
session_sca.virtwho_configure.edit(name, {'hypervisor_id': value})
results = session_sca.virtwho_configure.read(name)
org_session.virtwho_configure.edit(name, {'hypervisor_id': value})
results = org_session.virtwho_configure.read(name)
assert results['overview']['hypervisor_id'] == value
deploy_configure_by_command(
config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label
config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label
)
assert get_configure_option('hypervisor_id', config_file) == value
72 changes: 20 additions & 52 deletions tests/foreman/virtwho/ui/test_kubevirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,23 @@
:Upstream: No
"""
from fauxfactory import gen_string
import pytest

from robottelo.config import settings
from robottelo.utils.virtwho import (
deploy_configure_by_command,
deploy_configure_by_script,
get_configure_command,
get_configure_file,
get_configure_id,
get_configure_option,
)


@pytest.fixture()
def form_data():
form = {
'debug': True,
'interval': 'Every hour',
'hypervisor_id': 'hostname',
'hypervisor_type': settings.virtwho.kubevirt.hypervisor_type,
'hypervisor_content.kubeconfig': settings.virtwho.kubevirt.hypervisor_config_file,
}
return form


@pytest.fixture()
def virtwho_config(form_data, target_sat, session):
name = gen_string('alpha')
form_data['name'] = name
with session:
session.virtwho_configure.create(form_data)
yield virtwho_config
session.virtwho_configure.delete(name)
assert not session.virtwho_configure.search(name)


class TestVirtwhoConfigforKubevirt:
@pytest.mark.tier2
@pytest.mark.parametrize('deploy_type', ['id', 'script'])
@pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True)
def test_positive_deploy_configure_by_id_script(
self, default_org, virtwho_config, session, form_data, deploy_type
self, default_org, org_session, form_data_ui, deploy_type_ui
):
"""Verify configure created and deployed with id.
Expand All @@ -74,37 +49,30 @@ def test_positive_deploy_configure_by_id_script(
:CaseImportance: High
"""
name = form_data['name']
values = session.virtwho_configure.read(name)
if deploy_type == "id":
command = values['deploy']['command']
hypervisor_name, guest_name = deploy_configure_by_command(
command, form_data['hypervisor_type'], debug=True, org=default_org.label
)
elif deploy_type == "script":
script = values['deploy']['script']
hypervisor_name, guest_name = deploy_configure_by_script(
script, form_data['hypervisor_type'], debug=True, org=default_org.label
)
assert session.virtwho_configure.search(name)[0]['Status'] == 'ok'
hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name']
hypervisor_name, guest_name = deploy_type_ui
assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok'
hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name']
vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL'
vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED'
assert (
session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status']
org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][
'status'
]
== 'Unsubscribed hypervisor'
)
session.contenthost.add_subscription(hypervisor_display_name, vdc_physical)
assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green'
org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical)
assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green'
assert (
session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status']
org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status']
== 'Unentitled'
)
session.contenthost.add_subscription(guest_name, vdc_virtual)
assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green'
org_session.contenthost.add_subscription(guest_name, vdc_virtual)
assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green'

@pytest.mark.tier2
def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data):
def test_positive_hypervisor_id_option(
self, default_org, virtwho_config_ui, org_session, form_data_ui
):
"""Verify Hypervisor ID dropdown options.
:id: 09826cc0-aa49-4355-8980-8097511eb7d7
Expand All @@ -117,16 +85,16 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio
:CaseImportance: Medium
"""
name = form_data['name']
name = form_data_ui['name']
config_id = get_configure_id(name)
config_command = get_configure_command(config_id, default_org.name)
config_file = get_configure_file(config_id)
values = ['uuid', 'hostname']
for value in values:
session.virtwho_configure.edit(name, {'hypervisor_id': value})
results = session.virtwho_configure.read(name)
org_session.virtwho_configure.edit(name, {'hypervisor_id': value})
results = org_session.virtwho_configure.read(name)
assert results['overview']['hypervisor_id'] == value
deploy_configure_by_command(
config_command, form_data['hypervisor_type'], org=default_org.label
config_command, form_data_ui['hypervisor_type'], org=default_org.label
)
assert get_configure_option('hypervisor_id', config_file) == value
Loading

0 comments on commit a1dade8

Please sign in to comment.