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

Commit fe405a2

Browse files
committed
Added fixture to validate repo url from yaml
Signed-off-by: Ganesh Hubale <ghubale@redhat.com>
1 parent 1f5adbb commit fe405a2

2 files changed

Lines changed: 33 additions & 54 deletions

File tree

cfme/automate/explorer/domain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def step(self, *args, **kwargs):
494494
except CandidateNotFound:
495495
# Try it with regexp (drop the locked to None)
496496
# That will force reload from database
497-
self.obj.locked = None
497+
del self.obj.locked
498498
self.prerequisite_view.datastore.tree.click_path(*self.obj.tree_path)
499499

500500

cfme/tests/automate/test_git_import.py

Lines changed: 32 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@
1717
pytest.mark.meta(server_roles="+git_owner"),
1818
]
1919

20-
GIT_REPO_URL = None
2120

22-
try:
23-
GIT_REPO_URL = cfme_data.automate_links.datastore_repositories.manageiq_automate
24-
except AttributeError:
25-
pass
21+
@pytest.fixture
22+
def git_repo_url(appliance):
23+
try:
24+
repo_url = cfme_data.automate_links.datastore_repositories.manageiq_automate
25+
except AttributeError:
26+
pytest.skip(
27+
'No automate datastore is available at URL - '
28+
'cfme_data.automate_links.datastore_repositories.manageiq_automate'
29+
)
30+
return repo_url
2631

2732

2833
@pytest.fixture
29-
def imported_domain(appliance):
30-
if GIT_REPO_URL is None:
31-
pytest.skip('No automate repo url available at '
32-
'cfme_data.automate_links.datastore_repositories.manageiq_automate')
34+
def imported_domain(appliance, git_repo_url):
3335
repo = appliance.collections.automate_import_exports.instantiate(
34-
import_type="git", url=GIT_REPO_URL, verify_ssl=False
36+
import_type="git", url=git_repo_url, verify_ssl=False
3537
)
3638
domain = repo.import_domain_from(branch="origin/master")
3739
yield domain
@@ -57,7 +59,7 @@ def new_user(appliance):
5759

5860
@pytest.mark.tier(1)
5961
@pytest.mark.meta(automates=[BZ(1714493)])
60-
def test_automate_git_domain_removed_from_disk(appliance, imported_domain):
62+
def test_automate_git_domain_removed_from_disk(appliance, imported_domain, git_repo_url):
6163
"""
6264
Polarion:
6365
assignee: ghubale
@@ -67,14 +69,14 @@ def test_automate_git_domain_removed_from_disk(appliance, imported_domain):
6769
tags: automate
6870
"""
6971
imported_domain.delete()
70-
repo_path = urlparse(GIT_REPO_URL).path
72+
repo_path = urlparse(git_repo_url).path
7173
assert appliance.ssh_client.run_command(
7274
'[ ! -d "/var/www/vmdb/data/git_repos{}" ]'.format(repo_path)).success
7375

7476

7577
@pytest.mark.tier(2)
7678
@pytest.mark.meta(automates=[BZ(1714493)])
77-
def test_automate_git_domain_displayed_in_service(appliance):
79+
def test_automate_git_domain_displayed_in_service(request, appliance, git_repo_url):
7880
"""Tests if a domain is displayed in a service.
7981
Checks if the domain imported from git is displayed and usable in the pop-up tree in the
8082
dialog for creating services.
@@ -86,13 +88,11 @@ def test_automate_git_domain_displayed_in_service(appliance):
8688
initialEstimate: 1/20h
8789
tags: automate
8890
"""
89-
if GIT_REPO_URL is None:
90-
pytest.skip('No automate repo url available at '
91-
'cfme_data.automate_links.datastore_repositories.manageiq_automate')
9291
repo = appliance.collections.automate_import_exports.instantiate(
93-
import_type="git", url=GIT_REPO_URL, verify_ssl=True
92+
import_type="git", url=git_repo_url, verify_ssl=True
9493
)
9594
imported_domain = repo.import_domain_from(branch="origin/domain-display")
95+
request.addfinalizer(imported_domain.delete_if_exists)
9696
collection = appliance.collections.catalog_items
9797
cat_item = collection.instantiate(collection.GENERIC, "test")
9898
view = navigate_to(cat_item, "Add")
@@ -111,7 +111,7 @@ def test_automate_git_domain_displayed_in_service(appliance):
111111

112112
@pytest.mark.tier(3)
113113
@pytest.mark.meta(automates=[BZ(1714493)])
114-
def test_automate_git_import_multiple_domains(request, appliance):
114+
def test_automate_git_import_multiple_domains(request, appliance, git_repo_url):
115115
"""
116116
Importing of multiple domains from a single git repository is not allowed.
117117
@@ -133,11 +133,8 @@ def test_automate_git_import_multiple_domains(request, appliance):
133133
2.
134134
3. Import of multiple domains from a single git repo is not allowed
135135
"""
136-
if GIT_REPO_URL is None:
137-
pytest.skip('No automate repo url available at '
138-
'cfme_data.automate_links.datastore_repositories.manageiq_automate')
139136
repo = appliance.collections.automate_import_exports.instantiate(
140-
import_type="git", url=GIT_REPO_URL, verify_ssl=True
137+
import_type="git", url=git_repo_url, verify_ssl=True
141138
)
142139
with pytest.raises(AssertionError,
143140
match="Selected branch or tag contains more than one domain"):
@@ -174,7 +171,7 @@ def test_automate_git_import_multiple_domains(request, appliance):
174171
],
175172
ids=["with_branch", "with_tag", "with_top_level_domain", "without_top_level_domain"],
176173
)
177-
def test_domain_import_git(request, appliance, param_type, param_value, verify_ssl):
174+
def test_domain_import_git(request, appliance, param_type, param_value, verify_ssl, git_repo_url):
178175
"""This test case Verifies that a domain can be imported from git and Importing domain from git
179176
should work with or without the top level domain directory.
180177
@@ -200,11 +197,8 @@ def test_domain_import_git(request, appliance, param_type, param_value, verify_s
200197
Bugzilla:
201198
1389823
202199
"""
203-
if GIT_REPO_URL is None:
204-
pytest.skip('No automate repo url available at '
205-
'cfme_data.automate_links.datastore_repositories.manageiq_automate')
206200
repo = appliance.collections.automate_import_exports.instantiate(
207-
import_type="git", url=GIT_REPO_URL, verify_ssl=verify_ssl
201+
import_type="git", url=git_repo_url, verify_ssl=verify_ssl
208202
)
209203
domain = repo.import_domain_from(**{param_type: param_value})
210204
request.addfinalizer(domain.delete)
@@ -286,7 +280,7 @@ def test_refresh_git_current_user(imported_domain, new_user):
286280
@test_requirements.rest
287281
@pytest.mark.tier(3)
288282
@pytest.mark.ignore_stream("5.10")
289-
def test_domain_import_git_rest(appliance, request):
283+
def test_domain_import_git_rest(appliance, request, git_repo_url):
290284
"""
291285
This test checks importing datastore from git via REST
292286
@@ -311,12 +305,9 @@ def test_domain_import_git_rest(appliance, request):
311305
Bugzilla:
312306
1600961
313307
"""
314-
if GIT_REPO_URL is None:
315-
pytest.skip('No automate repo url available at '
316-
'cfme_data.automate_links.datastore_repositories.manageiq_automate')
317308
collection = appliance.rest_api.collections.automate_domains
318309
data = {
319-
"git_url": GIT_REPO_URL,
310+
"git_url": git_repo_url,
320311
"ref_type": "branch",
321312
"ref_name": "origin/master"
322313
}
@@ -335,7 +326,7 @@ def _cleanup():
335326

336327

337328
@pytest.mark.tier(1)
338-
def test_automate_git_import_case_insensitive(request, appliance):
329+
def test_automate_git_import_case_insensitive(request, appliance, git_repo_url):
339330
"""
340331
bin/rake evm:automate:import PREVIEW=false
341332
GIT_URL=https://github.com/RedHatQE/ManageIQ-automate-git REF=TestBranch
@@ -350,12 +341,8 @@ def test_automate_git_import_case_insensitive(request, appliance):
350341
tags: automate
351342
startsin: 5.7
352343
"""
353-
if GIT_REPO_URL is None:
354-
pytest.skip('No automate repo url available at '
355-
'cfme_data.automate_links.datastore_repositories.manageiq_automate')
356344
appliance.ssh_client.run_rake_command(
357-
"evm:automate:import PREVIEW=false "
358-
f"GIT_URL={GIT_REPO_URL}"
345+
f"evm:automate:import PREVIEW=false GIT_URL={git_repo_url}"
359346
)
360347
domain = appliance.collections.domains.instantiate(name="testdomain")
361348
request.addfinalizer(domain.delete_if_exists)
@@ -365,7 +352,8 @@ def test_automate_git_import_case_insensitive(request, appliance):
365352
@pytest.mark.tier(3)
366353
@pytest.mark.meta(automates=[1391208])
367354
@pytest.mark.parametrize("connection", [True, False], ids=["with_connection", "without_connection"])
368-
def test_automate_git_domain_import_connection(request, temp_appliance_preconfig, connection):
355+
def test_automate_git_domain_import_connection(request, git_repo_url, temp_appliance_preconfig,
356+
connection):
369357
"""
370358
Bugzilla:
371359
1391208
@@ -388,12 +376,9 @@ def test_automate_git_domain_import_connection(request, temp_appliance_preconfig
388376
3. The domain should be displayed properly
389377
"""
390378
# Server role 'git_owner' needs to enabled explicitly on temp_appliance_preconfig
391-
if GIT_REPO_URL is None:
392-
pytest.skip('No automate repo url available at '
393-
'cfme_data.automate_links.datastore_repositories.manageiq_automate')
394379
temp_appliance_preconfig.server.settings.enable_server_roles('git_owner')
395380
repo = temp_appliance_preconfig.collections.automate_import_exports.instantiate(
396-
import_type="git", url=GIT_REPO_URL, verify_ssl=True
381+
import_type="git", url=git_repo_url, verify_ssl=True
397382
)
398383
if connection:
399384
# Checking datastore import from github repository with internet connectivity
@@ -411,7 +396,7 @@ def test_automate_git_domain_import_connection(request, temp_appliance_preconfig
411396

412397
@pytest.mark.tier(3)
413398
@pytest.mark.meta(automates=[1508881])
414-
def test_automate_git_import_without_master(appliance, request):
399+
def test_automate_git_import_without_master(appliance, request, git_repo_url):
415400
"""
416401
Bugzilla:
417402
1508881
@@ -431,11 +416,8 @@ def test_automate_git_import_without_master(appliance, request):
431416
2.
432417
3. Domain was imported from git
433418
"""
434-
if GIT_REPO_URL is None:
435-
pytest.skip('No automate repo url available at '
436-
'cfme_data.automate_links.datastore_repositories.manageiq_automate')
437419
repo = appliance.collections.automate_import_exports.instantiate(
438-
import_type="git", url=GIT_REPO_URL, verify_ssl=False
420+
import_type="git", url=git_repo_url, verify_ssl=False
439421
)
440422
domain = repo.import_domain_from(branch="origin/testbranch")
441423
request.addfinalizer(domain.delete_if_exists)
@@ -550,7 +532,7 @@ def test_automate_git_import_deleted_tag(appliance, imported_domain):
550532

551533
@pytest.mark.tier(1)
552534
@pytest.mark.meta(automates=[1716443])
553-
def test_git_refresh_with_renamed_yaml(appliance):
535+
def test_git_refresh_with_renamed_yaml(appliance, git_repo_url):
554536
"""
555537
Note: In this test case, we are checking that datastore with broken __domain__.yml should not
556538
get imported. But this BZ says, automate namespace, class, instance, method under domain should
@@ -573,11 +555,8 @@ def test_git_refresh_with_renamed_yaml(appliance):
573555
expectedResults:
574556
1. Domain should not get imported
575557
"""
576-
if GIT_REPO_URL is None:
577-
pytest.skip('No automate repo url available at '
578-
'cfme_data.automate_links.datastore_repositories.manageiq_automate')
579558
repo = appliance.collections.automate_import_exports.instantiate(
580-
import_type="git", url=GIT_REPO_URL
559+
import_type="git", url=git_repo_url
581560
)
582561
with pytest.raises(AssertionError, match=(
583562
"Error: import failed: Selected branch or tag does not contain a valid domain"

0 commit comments

Comments
 (0)