-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternate Content Source UI tests #12649
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM code-wise, but not an ACS expert though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, the test just does what I would expect it to do - tests the UI.
Good job @LadislavVasina1 !
tests/foreman/ui/test_acs.py
Outdated
8. Test editing urls and subpaths | ||
9. Test editing credentials | ||
10. Test editing products | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codewise I see no problems but I'm not convinced of this all being in a single test. If there is a bug in creation of just of the types in step 2 we never get to testing other things, with 10 types it is not so improbable.
IIUC the ACSes in edit and rename steps are just selected randomly, and there are special ones created to test deletion anyway.
My suggestion is to have a separate test for step 2 -- check all types can be created
.
And then have a separate e2e test
for the other steps, just move the deletion part at the very end.
Bonus suggestion: consider what it would take to have ACS configuration for the individual types defined in some structure and then use that to parametrize the tests. For the check all types can be created
test it would ensure all types are always tested (currently, if the first one fails others are not visited). For the e2e
test, we could pick one or more types for coverage, or a random one perhaps :)
b1845b7
to
95d2ad7
Compare
trigger: test-robottelo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to re-do the structure of the test, to separate the parametrization logic from the test body:
you define a function to generate the payload data and nice test id strings (I only picked some of the params you use in your tests for the demonstration purposes, you might want to add the missing ones yourself):
def gen_params():
a = {
'_common': {
'use_http_proxies': True,
},
'custom': {
'_common': {
'custom_type': True,
'base_url': 'https://test.com/',
'subpaths': ['test/'],
},
'yum': {
'content_type': 'yum'
},
'file': {}
},
'simplified': {
'_common': {
'simplified_type': True
},
'yum': {
'content_type': 'yum',
'name': 'simpleYum',
'description': 'simpleYumDesc',
'capsules_to_add': class_target_sat.hostname,
'products_to_add': [constants.REPOS[repo]['product'] for repo in repos_to_enable]
},
'file': {
'content_type': 'file',
'name': 'simpleFile',
'description': 'simpleFileDesc',
'add_all_capsules': True,
'products_to_add': product_name,
},
},
'rhui': {
'yum': {
'rhui_type': True,
'name': 'rhuiYumNoneAuth',
'base_url': 'https://test.com/pulp/content',
'subpaths': ['test/', 'test2/'],
},
}
}
ids = []
vals = []
for acs in a.keys():
if not acs.startswith('_'):
for cnt in a[acs]:
if not cnt.startswith('_'):
scenario = a[acs][cnt] | a.get('_common', {}) | a[acs].get('_common', {})
ids.append(f'{acs}_{cnt}')
vals.append(scenario)
return (vals, ids)
and here's how you use it in your test
@pytest.mark.parametrize('scenario, gen_params()[0], ids=gen_params()[1]) # you put a call to the function into the parametrize call like so
def test_param(scenario):
....
session.acs.create_new_acs(**scenario) # and you access the function payload per current scenario like so
pass
This generates the following tests with the following "payload":
$ pytest -vs test_foo.py
==== test session starts ====
...
collected 5 items
test_foo.py::test_param[custom_yum] {'content_type': 'yum', 'use_http_proxies': True, 'custom_type': True, 'base_url': 'https://test.com', 'subpaths': ['test/']}
PASSED
test_foo.py::test_param[custom_file] {'use_http_proxies': True, 'custom_type': True, 'base_url': 'https://test.com', 'subpaths': ['test/']}
PASSED
test_foo.py::test_param[simplified_yum] {'content_type': 'yum', 'name': 'simpleYum', 'description': 'simpleYumDesc', 'capsules_to_add': 'placeholder', 'products_to_add': [1, 2, 3], 'use_http_proxies': True, 'simplified_type': True}
PASSED
test_foo.py::test_param[simplified_file] {'content_type': 'file', 'name': 'simpleFile', 'description': 'simpleFileDesc', 'add_all_capsules': True, 'products_to_add': 'placeholder', 'use_http_proxies': True, 'simplified_type': True}
PASSED
test_foo.py::test_param[rhui_yum] {'rhui_type': True, 'name': 'rhuiYumNoneAuth', 'base_url': 'https://test.com/pulp/content', 'subpaths': ['test/', 'test2/'], 'use_http_proxies': True}
PASSED
While at it, you can extend the dictionary with the auth
parameter too and break those test cases into smaller, individual ones.
8b16950
to
1bd5110
Compare
trigger: test-robottelo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! thanks for addressing my comments. I appreciate it.
In this PR I have implemented two tests. One end-to-end UI test tests the creation of some ACS types and actions on them and the second one tests the creation of all possible ACS types.