From d639953a4c93f8ed6b8b1259f615241fedd21725 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Wed, 29 Jan 2025 17:13:31 -0500 Subject: [PATCH] Removing some (but not all) dead pytest fixtures (#15782) * Try removing dead fixtures * Add back in EE fixture --- awx/main/tests/conftest.py | 5 ---- .../test_deprecated_credential_assignment.py | 6 ---- .../tests/functional/api/test_inventory.py | 9 ------ .../functional/api/test_job_runtime_params.py | 5 ---- awx/main/tests/functional/conftest.py | 30 ------------------- .../tests/functional/tasks/test_tasks_jobs.py | 10 ------- 6 files changed, 65 deletions(-) diff --git a/awx/main/tests/conftest.py b/awx/main/tests/conftest.py index fbfb6489f009..71e9637ed9e8 100644 --- a/awx/main/tests/conftest.py +++ b/awx/main/tests/conftest.py @@ -140,11 +140,6 @@ def rf(persisted): return rf -@pytest.fixture -def job_with_secret_key_unit(job_with_secret_key_factory): - return job_with_secret_key_factory(persisted=False) - - @pytest.fixture def workflow_job_template_factory(): return create_workflow_job_template diff --git a/awx/main/tests/functional/api/test_deprecated_credential_assignment.py b/awx/main/tests/functional/api/test_deprecated_credential_assignment.py index 266218c0cb23..02937c184514 100644 --- a/awx/main/tests/functional/api/test_deprecated_credential_assignment.py +++ b/awx/main/tests/functional/api/test_deprecated_credential_assignment.py @@ -6,12 +6,6 @@ from awx.api.versioning import reverse -@pytest.fixture -def ec2_source(inventory, project): - with mock.patch('awx.main.models.unified_jobs.UnifiedJobTemplate.update'): - return inventory.inventory_sources.create(name='some_source', source='ec2', source_project=project) - - @pytest.fixture def job_template(job_template, project, inventory): job_template.playbook = 'helloworld.yml' diff --git a/awx/main/tests/functional/api/test_inventory.py b/awx/main/tests/functional/api/test_inventory.py index 71a48383c409..484c6035f813 100644 --- a/awx/main/tests/functional/api/test_inventory.py +++ b/awx/main/tests/functional/api/test_inventory.py @@ -17,15 +17,6 @@ def scm_inventory(inventory, project): return inventory -@pytest.fixture -def factory_scm_inventory(inventory, project): - def fn(**kwargs): - with mock.patch('awx.main.models.unified_jobs.UnifiedJobTemplate.update'): - return inventory.inventory_sources.create(source_project=project, overwrite_vars=True, source='scm', **kwargs) - - return fn - - @pytest.mark.django_db def test_inventory_source_notification_on_cloud_only(get, post, inventory_source_factory, user, notification_template): u = user('admin', True) diff --git a/awx/main/tests/functional/api/test_job_runtime_params.py b/awx/main/tests/functional/api/test_job_runtime_params.py index f893b53c66f0..95b55e15b601 100644 --- a/awx/main/tests/functional/api/test_job_runtime_params.py +++ b/awx/main/tests/functional/api/test_job_runtime_params.py @@ -38,11 +38,6 @@ def runtime_data(organization, credentialtype_ssh): ) -@pytest.fixture -def job_with_links(machine_credential, inventory): - return Job.objects.create(name='existing-job', credential=machine_credential, inventory=inventory) - - @pytest.fixture def job_template_prompts(project, inventory, machine_credential): def rf(on_off): diff --git a/awx/main/tests/functional/conftest.py b/awx/main/tests/functional/conftest.py index 8fca93e7f9d2..13c2fd53389e 100644 --- a/awx/main/tests/functional/conftest.py +++ b/awx/main/tests/functional/conftest.py @@ -186,12 +186,6 @@ def factory(name): return factory -@pytest.fixture -def user_project(user): - owner = user('owner') - return Project.objects.create(name="test-user-project", created_by=owner, description="test-user-project-desc") - - @pytest.fixture def insights_project(): return Project.objects.create(name="test-insights-project", scm_type="insights") @@ -341,13 +335,6 @@ def inventory(organization): return organization.inventories.create(name="test-inv") -@pytest.fixture -def insights_inventory(inventory): - inventory.scm_type = 'insights' - inventory.save() - return inventory - - @pytest.fixture def scm_inventory_source(inventory, project): inv_src = InventorySource( @@ -497,23 +484,6 @@ def g(name): return g -@pytest.fixture -def hosts(group_factory): - group1 = group_factory('group-1') - - def rf(host_count=1): - hosts = [] - for i in range(0, host_count): - name = '%s-host-%s' % (group1.name, i) - (host, created) = group1.inventory.hosts.get_or_create(name=name) - if created: - group1.hosts.add(host) - hosts.append(host) - return hosts - - return rf - - @pytest.fixture def group(inventory): return inventory.groups.create(name='single-group') diff --git a/awx/main/tests/functional/tasks/test_tasks_jobs.py b/awx/main/tests/functional/tasks/test_tasks_jobs.py index a627731bbb25..6f104b0207d9 100644 --- a/awx/main/tests/functional/tasks/test_tasks_jobs.py +++ b/awx/main/tests/functional/tasks/test_tasks_jobs.py @@ -1,19 +1,9 @@ import pytest -import os from awx.main.tasks.jobs import RunJob from awx.main.models import Job -@pytest.fixture -def scm_revision_file(tmpdir_factory): - # Returns path to temporary testing revision file - revision_file = tmpdir_factory.mktemp('revisions').join('revision.txt') - with open(str(revision_file), 'w') as f: - f.write('1234567890123456789012345678901234567890') - return os.path.join(revision_file.dirname, 'revision.txt') - - @pytest.mark.django_db def test_does_not_run_reaped_job(mocker, mock_me): job = Job.objects.create(status='failed', job_explanation='This job has been reaped.')