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

[1LP][RFR] Add test_compare_provider_templates to test_providers.py #9424

Merged
merged 20 commits into from
Mar 5, 2020

Conversation

prichard77
Copy link
Contributor

@prichard77 prichard77 commented Sep 26, 2019

Purpose or Intent

  • Adding tests for BZ 1746449. This covers the comparison of provider templates.

PRT Run

{{ pytest: --use-provider complete --long-running cfme/tests/infrastructure/test_providers.py::test_compare_provider_templates}}

@prichard77 prichard77 changed the title [WIP] Add test_compare_provider_templates to test_providers.py [WIPTEST] Add test_compare_provider_templates to test_providers.py Oct 18, 2019
@dajoRH dajoRH added WIP-testing and removed WIP labels Oct 18, 2019
@prichard77 prichard77 changed the title [WIPTEST] Add test_compare_provider_templates to test_providers.py [WIP] Add test_compare_provider_templates to test_providers.py Nov 12, 2019
@prichard77 prichard77 changed the title [WIP] Add test_compare_provider_templates to test_providers.py [WIPTEST] Add test_compare_provider_templates to test_providers.py Jan 23, 2020


def verify_checked_items_compared(checkedList, view):
for e in view.comparison_table.headers[1:-1]:
Copy link
Member

Choose a reason for hiding this comment

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

Please clean up these magic numbers, indexing, and using single character vars.

What is e? standing for here?

What are you indexing out of the headers? Let's comment in-line and name it more descriptively.

Below, what's the function of the split and zero-index? Again let's descriptively name what this value is.

Why use try/except around a remove, instead of directly asserting that the item from the checked list is in the list of header values?

I think you could use two set objects to verify the list of headers and list of items that had been selected are the same.

Consider having this as a method in the ComparisonView class, instead of just a function within the test module. That way its re-usable across the various entities in MIQ that can be compared, and can be used outside of this test module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll make the vars more descriptive, add some inline comments. I could put in a function like get_templates_on_page() and put the 'magic' in there. This is all a result of what is contained in .headers. The values returned, except for the fitst and last are the templates in the view. The first and last items are just part of the table. So I used [1:-1] on these. I'll add an inline comment. Then the template-like names have additional characters added to them so I split on space and take the first([0]) item. I'll make this clearer.

I was using try/except because it enabled me to distinguish between missing and extra templates in the view and would stop as soon as a failure was found. But "set" might be a good solution also. I'll look into it.

I agree with putting this functionality into methods for the view classes, and am working on this now in another PR. I am starting with implementing comparison for hosts while investigating what would be needed to extend to templates and datastores. I'd really like to get this test merged and running while I work on the optimization.

The changes are forthcoming, but I wanted to continue the discussion. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed some changes but realize we have more discussion and changes to come.

Copy link
Contributor Author

@prichard77 prichard77 Jan 31, 2020

Choose a reason for hiding this comment

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

I take it you are suggesting creating sets from the 2 lists and taking the symmetric difference. If It's non-zero we have a failure. Only thing is, it takes more steps to determine which lists have the extra/missing items. Or are you suggesting something else?

@mshriver mshriver changed the title [1LP][RFR] Add test_compare_provider_templates to test_providers.py [1LP][WIPTEST] Add test_compare_provider_templates to test_providers.py Jan 30, 2020
@dajoRH dajoRH added needs-lint and removed lint-ok labels Jan 30, 2020
setup_or_skip(request, provider)


def verify_checked_items_compared(checkedList, view):
Copy link
Member

Choose a reason for hiding this comment

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

TODO: move this method into the comparison view.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done as requested.

@pytest.fixture
def setup_provider_min_templates(request, appliance, provider, min_templates):
templates_yaml = len(provider.data.get('templates', {}))
if templates_yaml < min_templates:
Copy link
Member

Choose a reason for hiding this comment

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

I think you'll want to skip this check for this test context, as the number of templates in the yaml is almost always going to be lower than the actual number of templates available. We only define in the yaml the templates that we use for provisioning tests, and I think this ends up too restrictive - currently skipping for 4 templates against both versions of rhv and scvmm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated as requested.

@dajoRH
Copy link
Contributor

dajoRH commented Jan 31, 2020

I detected some fixture changes in commit 7d29557

The local fixture setup_provider_min_templates is used in the following files:

  • cfme/tests/infrastructure/test_providers.py
    • test_compare_provider_templates

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

@dajoRH dajoRH added lint-ok and removed needs-lint labels Feb 20, 2020
@prichard77 prichard77 changed the title [1LP][WIPTEST] Add test_compare_provider_templates to test_providers.py [1LP][RFR] Add test_compare_provider_templates to test_providers.py Feb 24, 2020
@mshriver mshriver changed the title [1LP][RFR] Add test_compare_provider_templates to test_providers.py [1LP][WIPTEST] Add test_compare_provider_templates to test_providers.py Feb 28, 2020
@prichard77
Copy link
Contributor Author

I am not sure what is missing here and why this is not in RFR. I'll keep looking and see what I can determine.

@prichard77
Copy link
Contributor Author

I can't find any reason this is not in RFR. Updating to RFR.

@prichard77 prichard77 changed the title [1LP][WIPTEST] Add test_compare_provider_templates to test_providers.py [1LP][RFR] Add test_compare_provider_templates to test_providers.py Mar 4, 2020
@dajoRH dajoRH removed the WIP-testing label Mar 4, 2020
@mshriver mshriver merged commit a9736ee into ManageIQ:master Mar 5, 2020
@prichard77 prichard77 deleted the compareTemplates branch March 6, 2020 15:50
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