Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

[1LP][RFR] Passed template name as string instead of function #9614

Merged
merged 1 commit into from
Nov 15, 2019

Conversation

sshveta
Copy link
Contributor

@sshveta sshveta commented Nov 12, 2019

{{ pytest: cfme/tests/v2v/test_v2v_migrations_single_vcenter.py --use-provider rhv43 --use-provider vsphere67-ims --provider-limit 2 -vvvv --long-running -k test_migration_long_name }}

Made changes to pass template name as string instead of function to fix test failure

         vm_obj = collection.instantiate(
        >           vm_name, source_provider, template_name=template["name"] )
        E       TypeError: 'function' object is not subscriptable`

@dajoRH dajoRH added the lint-ok label Nov 12, 2019
@john-dupuy
Copy link
Contributor

john-dupuy commented Nov 12, 2019

@sshveta So if I am understanding this right, the issue you're trying to solve here is a pytest issue (pytest-dev/pytest#349). I am partial towards a solution (e.g. for https://github.com/ManageIQ/integration_tests/blob/master/cfme/tests/v2v/test_v2v_migrations.py#L311) that would look something like:

@pytest.mark.parametrize(
    "mapping_data_multiple_vm_obj_single_datastore",
    [
        ["nfs", "nfs", [lambda provider: _get_template(provider, 'win7_template')]],
        ["nfs", "nfs", [lambda provider: _get_template(provider, 'win10_template')]],
        ["nfs", "nfs", [lambda provider: _get_template(provider, 'win2016_template')]],
        ["nfs", "nfs", [lambda provider: _get_template(provider, 'rhel69_template')]],
        ["nfs", "nfs", [lambda provider: _get_template(provider, 'win2012_template')]],
        ["nfs", "nfs", [lambda provider: _get_template(provider, 'ubuntu16_template')]],
    ],
    indirect=True,
)

This way you can still get the template name through template.name. @mshriver @jawatts @izapolsk thoughts on an approach like this one? Is there a better approach to parametrize these tests based on fixtures?

@sshveta sshveta force-pushed the pass_template_as_string branch from b774d17 to a55ccf3 Compare November 14, 2019 05:52
@dajoRH dajoRH changed the title [RFR] Passed template name as string instead of function [WIP] Passed template name as string instead of function Nov 14, 2019
@dajoRH dajoRH added needs-lint and removed lint-ok labels Nov 14, 2019
@sshveta sshveta force-pushed the pass_template_as_string branch from 2f0ab41 to a693b66 Compare November 14, 2019 06:08
@sshveta sshveta changed the title [WIP] Passed template name as string instead of function [RFR] Passed template name as string instead of function Nov 14, 2019
@dajoRH dajoRH added lint-ok and removed needs-lint labels Nov 14, 2019
@dajoRH dajoRH changed the title [RFR] Passed template name as string instead of function [WIP] Passed template name as string instead of function Nov 14, 2019
@dajoRH dajoRH added needs-lint and removed lint-ok labels Nov 14, 2019
@sshveta sshveta changed the title [WIP] Passed template name as string instead of function [RFR] Passed template name as string instead of function Nov 14, 2019
@dajoRH dajoRH added lint-ok and removed needs-lint labels Nov 14, 2019
@sshveta sshveta force-pushed the pass_template_as_string branch from c25cf74 to 874d784 Compare November 15, 2019 06:02
@dajoRH dajoRH changed the title [RFR] Passed template name as string instead of function [WIP] Passed template name as string instead of function Nov 15, 2019
@ManageIQ ManageIQ deleted a comment from dajoRH Nov 15, 2019
@sshveta sshveta changed the title [WIP] Passed template name as string instead of function [RFR] Passed template name as string instead of function Nov 15, 2019
@mshriver mshriver self-assigned this Nov 15, 2019
Copy link
Contributor

@john-dupuy john-dupuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of the enum class! Some minor questions and suggestion, please take a look.

cfme/fixtures/v2v_fixtures.py Outdated Show resolved Hide resolved
cfme/fixtures/v2v_fixtures.py Outdated Show resolved Hide resolved
cfme/tests/v2v/test_v2v_migrations_single_vcenter.py Outdated Show resolved Hide resolved
@sshveta sshveta force-pushed the pass_template_as_string branch from a8f5ff3 to c6dd476 Compare November 15, 2019 20:14
@dajoRH
Copy link
Contributor

dajoRH commented Nov 15, 2019

I detected some fixture changes in commit c6dd476

Show fixtures

The global fixture mapping_data_vm_obj_mini is used in the following files:

  • cfme/tests/v2v/test_post_migrations.py
    • test_migration_post_attribute
  • cfme/tests/v2v/test_v2v_cancel_migrations.py
    • cancel_migration_plan
  • cfme/tests/v2v/test_v2v_migrations_single_vcenter.py
  • cfme/tests/v2v/test_v2v_migrations_ui.py
    • test_duplicate_plan_name
    • test_duplicate_mapping_name
  • cfme/tests/v2v/test_v2v_schedule_migrations.py
    • test_schedule_migration

The global fixture mapping_data_multiple_vm_obj_single_datastore is used in the following files:

  • cfme/tests/v2v/test_migration_throttling.py
  • cfme/tests/v2v/test_v2v_cancel_migrations.py
  • cfme/tests/v2v/test_v2v_migrations.py
  • cfme/tests/v2v/test_v2v_migrations_single_vcenter.py
  • cfme/tests/v2v/test_v2v_smoke.py

The global fixture mapping_data_single_datastore was changed, but I didn't find where it's used.
The global fixture mapping_data_single_network was changed, but I didn't find where it's used.
The global fixture mapping_data_dual_vm_obj_dual_datastore is used in the following files:

  • cfme/tests/v2v/test_v2v_migrations.py

The global fixture mapping_data_vm_obj_dual_nics is used in the following files:

  • cfme/tests/v2v/test_v2v_migrations.py

The global fixture mapping_data_vm_obj_single_datastore is used in the following files:

  • cfme/tests/v2v/test_v2v_ansible.py
  • cfme/tests/v2v/test_v2v_cancel_migrations.py
  • cfme/tests/v2v/test_v2v_migrations.py
  • cfme/tests/v2v/test_v2v_migrations_single_vcenter.py
  • cfme/tests/v2v/test_v2v_migrations_ui.py

The global fixture mapping_data_vm_obj_single_network is used in the following files:

  • cfme/tests/v2v/test_v2v_migrations.py

Please, consider creating a PRT run to make sure your fixture changes do not break existing usage 😃

Copy link
Member

@mshriver mshriver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking solid to me, thanks for your patience @sshveta! Let's wait on some PRT results and be sure we want the resulting test case ID's before all the polarion churn.

@john-dupuy john-dupuy changed the title [RFR] Passed template name as string instead of function [1LP][RFR] Passed template name as string instead of function Nov 15, 2019
@mshriver mshriver merged commit 5109914 into ManageIQ:master Nov 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants