-
Notifications
You must be signed in to change notification settings - Fork 165
[1LP][RFR] New Test: Testing associated vm storages using automate method #9806
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.
Awesome test case @ganeshhubale, looks good to me!
4. Returns available storages | ||
""" | ||
list_storages = dedent( | ||
f'vmware = $evm.vmdb("ems").find_by_name("{provider.name}")\n' |
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.
As we are using dedent
, why not use full script?
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 agree @digitronik
- But I am not able to format this line using fstring or .format(
vm = vmware.vms.select {|v| v.name == "{testing_vm.name}"}.first
) because of extra{}
. - Hence I modified this script in this way. Please let me know if you have a solution for formatting this script.
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.
This can be done in either with a double {
character.
In [8]: storages = (f'vmware = $evm.vmdb("ems").find_by_name("{provider_name}")\n'
...: f'vm = vmware.vms.select {{|v| v.name == "{test_vm_name}"}}.first\n'
...: )
In [9]: storages
Out[9]: 'vmware = $evm.vmdb("ems").find_by_name("test_provider_name")\nvm = vmware.vms.select {|v| v.name == "test_virtual_machine"}.first\n'
The single braced expressions are evaluated, the double braced characters result in a single brace in the resulting string.
https://docs.python.org/3.7/reference/lexical_analysis.html#formatted-string-literals
First paragraph below the code block.
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.
That said, the formatting change can be a followup, I won't block merging on this. The use of dedent and multiple lines makes it clear what is being evaluated and what is not.
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.
Looks good to me - holding merge on PRT results. Last run is false-positive, the cases skipped because of provisioning timeouts.
Purpose or Intent
PRT Run
{{ pytest: cfme/tests/automate/test_common_methods.py -k 'test_list_of_diff_vm_storages_via_rails' --use-provider complete --use-template-cache -qsvvv }}