Skip to content

Commit

Permalink
Removing some (but not all) dead pytest fixtures (#15782)
Browse files Browse the repository at this point in the history
* Try removing dead fixtures

* Add back in EE fixture
  • Loading branch information
AlanCoding authored Jan 29, 2025
1 parent c6930bd commit d639953
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 65 deletions.
5 changes: 0 additions & 5 deletions awx/main/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
9 changes: 0 additions & 9 deletions awx/main/tests/functional/api/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions awx/main/tests/functional/api/test_job_runtime_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
30 changes: 0 additions & 30 deletions awx/main/tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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')
Expand Down
10 changes: 0 additions & 10 deletions awx/main/tests/functional/tasks/test_tasks_jobs.py
Original file line number Diff line number Diff line change
@@ -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.')
Expand Down

0 comments on commit d639953

Please sign in to comment.