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

Commit 2f65347

Browse files
Fix test_ansible_service_linked_vm
1 parent a97c9d7 commit 2f65347

File tree

2 files changed

+42
-13
lines changed

2 files changed

+42
-13
lines changed

cfme/fixtures/ansible_fixtures.py

+33-4
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,34 @@ def ansible_catalog_item(appliance, ansible_repository):
145145
cat_item.delete_if_exists()
146146

147147

148+
@pytest.fixture(scope="function")
149+
def ansible_catalog_item_funcscope(appliance, ansible_repository):
150+
collection = appliance.collections.catalog_items
151+
cat_item = collection.create(
152+
collection.ANSIBLE_PLAYBOOK,
153+
fauxfactory.gen_alphanumeric(),
154+
fauxfactory.gen_alphanumeric(),
155+
display_in_catalog=True,
156+
provisioning={
157+
"repository": ansible_repository.name,
158+
"playbook": "dump_all_variables.yml",
159+
"machine_credential": "CFME Default Credential",
160+
"create_new": True,
161+
"provisioning_dialog_name": fauxfactory.gen_alphanumeric(),
162+
"extra_vars": [("some_var", "some_value")]
163+
},
164+
retirement={
165+
"repository": ansible_repository.name,
166+
"playbook": "dump_all_variables.yml",
167+
"machine_credential": "CFME Default Credential",
168+
"extra_vars": [("some_var", "some_value")]
169+
}
170+
)
171+
yield cat_item
172+
173+
cat_item.delete_if_exists()
174+
175+
148176
@pytest.fixture(scope="module")
149177
def ansible_catalog(appliance, ansible_catalog_item):
150178
catalog = appliance.collections.catalogs.create(fauxfactory.gen_alphanumeric(),
@@ -165,8 +193,9 @@ def ansible_service_catalog(appliance, ansible_catalog_item, ansible_catalog):
165193

166194

167195
@pytest.fixture(scope="function")
168-
def ansible_service_request_funcscope(appliance, ansible_catalog_item):
169-
request_descr = "Provisioning Service [{0}] from [{0}]".format(ansible_catalog_item.name)
196+
def ansible_service_request_funcscope(appliance, ansible_catalog_item_funcscope):
197+
request_descr = (f"Provisioning Service [{ansible_catalog_item_funcscope}]"
198+
"from [{ansible_catalog_item_funcscope}]")
170199
service_request = appliance.collections.requests.instantiate(description=request_descr)
171200
yield service_request
172201

@@ -176,8 +205,8 @@ def ansible_service_request_funcscope(appliance, ansible_catalog_item):
176205

177206

178207
@pytest.fixture(scope="function")
179-
def ansible_service_funcscope(appliance, ansible_catalog_item):
180-
service = MyService(appliance, ansible_catalog_item.name)
208+
def ansible_service_funcscope(appliance, ansible_catalog_item_funcscope):
209+
service = MyService(appliance, ansible_catalog_item_funcscope.name)
181210
yield service
182211

183212
if service.exists:

cfme/tests/ansible/test_embedded_ansible_services.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ def _finalize():
135135

136136

137137
@pytest.fixture()
138-
def ansible_linked_vm_action(appliance, local_ansible_catalog_item, create_vm):
139-
with update(local_ansible_catalog_item):
140-
local_ansible_catalog_item.provisioning = {"playbook": "add_single_vm_to_service.yml"}
138+
def ansible_linked_vm_action(appliance, ansible_catalog_item_funcscope, create_vm):
139+
with update(ansible_catalog_item_funcscope):
140+
ansible_catalog_item_funcscope.provisioning = {"playbook": "add_single_vm_to_service.yml"}
141141

142142
action_values = {
143143
"run_ansible_playbook": {
144-
"playbook_catalog_item": local_ansible_catalog_item.name,
144+
"playbook_catalog_item": ansible_catalog_item_funcscope.name,
145145
"inventory": {"specific_hosts": True, "hosts": create_vm.ip_address},
146146
}
147147
}
@@ -858,8 +858,8 @@ def test_ansible_service_linked_vm(
858858
appliance,
859859
create_vm,
860860
ansible_policy_linked_vm,
861-
ansible_service_request,
862-
ansible_service,
861+
ansible_service_request_funcscope,
862+
ansible_service_funcscope,
863863
request,
864864
):
865865
"""Check Whether service has associated VM attached to it.
@@ -874,10 +874,10 @@ def test_ansible_service_linked_vm(
874874
tags: ansible_embed
875875
"""
876876
create_vm.add_tag()
877-
wait_for(ansible_service_request.exists, num_sec=600)
878-
ansible_service_request.wait_for_request()
877+
wait_for(ansible_service_request_funcscope.exists, num_sec=600)
878+
ansible_service_request_funcscope.wait_for_request()
879879

880-
view = navigate_to(ansible_service, "Details")
880+
view = navigate_to(ansible_service_funcscope, "Details")
881881
assert create_vm.name in view.entities.vms.all_entity_names
882882

883883

0 commit comments

Comments
 (0)