mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 18:07:36 -02:30
Fix flake8 E302 errors.
This commit is contained in:
@@ -43,6 +43,7 @@ from awx.main.models.notifications import (
|
||||
Notification
|
||||
)
|
||||
|
||||
|
||||
'''
|
||||
Disable all django model signals.
|
||||
'''
|
||||
@@ -62,6 +63,7 @@ Allows django signal code to execute without the need for redis
|
||||
def celery_memory_broker():
|
||||
settings.BROKER_URL='memory://localhost/'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user():
|
||||
def u(name, is_superuser=False):
|
||||
@@ -73,6 +75,7 @@ def user():
|
||||
return user
|
||||
return u
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_jobtemplate(project, inventory, credential):
|
||||
return \
|
||||
@@ -84,6 +87,7 @@ def check_jobtemplate(project, inventory, credential):
|
||||
name='check-job-template'
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def deploy_jobtemplate(project, inventory, credential):
|
||||
return \
|
||||
@@ -95,10 +99,12 @@ def deploy_jobtemplate(project, inventory, credential):
|
||||
name='deploy-job-template'
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def team(organization):
|
||||
return organization.teams.create(name='test-team')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def team_member(user, team):
|
||||
ret = user('team-member', False)
|
||||
@@ -116,6 +122,7 @@ def project(instance, organization):
|
||||
)
|
||||
return prj
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def project_factory(organization):
|
||||
def factory(name):
|
||||
@@ -129,12 +136,14 @@ def project_factory(organization):
|
||||
return prj
|
||||
return factory
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def job_factory(job_template, admin):
|
||||
def factory(job_template=job_template, initial_state='new', created_by=admin):
|
||||
return job_template.create_job(created_by=created_by, status=initial_state)
|
||||
return factory
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def team_factory(organization):
|
||||
def factory(name):
|
||||
@@ -147,35 +156,43 @@ def team_factory(organization):
|
||||
return t
|
||||
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 instance(settings):
|
||||
return Instance.objects.create(uuid=settings.SYSTEM_UUID, hostname="instance.example.org", capacity=100)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def organization(instance):
|
||||
return Organization.objects.create(name="test-org", description="test-org-desc")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def credential():
|
||||
return Credential.objects.create(kind='aws', name='test-cred', username='something', password='secret')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def machine_credential():
|
||||
return Credential.objects.create(name='machine-cred', kind='ssh', username='test_user', password='pas4word')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def org_credential(organization):
|
||||
return Credential.objects.create(kind='aws', name='test-cred', username='something', password='secret', organization=organization)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inventory(organization):
|
||||
return organization.inventories.create(name="test-inv")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inventory_factory(organization):
|
||||
def factory(name, org=organization):
|
||||
@@ -186,10 +203,12 @@ def inventory_factory(organization):
|
||||
return inv
|
||||
return factory
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def label(organization):
|
||||
return organization.labels.create(name="test-label", description="test-label-desc")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def notification_template(organization):
|
||||
return NotificationTemplate.objects.create(name='test-notification_template',
|
||||
@@ -198,6 +217,7 @@ def notification_template(organization):
|
||||
notification_configuration=dict(url="http://localhost",
|
||||
headers={"Test": "Header"}))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def notification(notification_template):
|
||||
return Notification.objects.create(notification_template=notification_template,
|
||||
@@ -207,27 +227,33 @@ def notification(notification_template):
|
||||
recipients='admin@redhat.com',
|
||||
subject='email subject')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def job_template_with_survey_passwords(job_template_with_survey_passwords_factory):
|
||||
return job_template_with_survey_passwords_factory(persisted=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def admin(user):
|
||||
return user('admin', True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def alice(user):
|
||||
return user('alice', False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bob(user):
|
||||
return user('bob', False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def rando(user):
|
||||
"Rando, the random user that doesn't have access to anything"
|
||||
return user('rando', False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def org_admin(user, organization):
|
||||
ret = user('org-admin', False)
|
||||
@@ -235,6 +261,7 @@ def org_admin(user, organization):
|
||||
organization.member_role.members.add(ret)
|
||||
return ret
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def org_auditor(user, organization):
|
||||
ret = user('org-auditor', False)
|
||||
@@ -242,12 +269,14 @@ def org_auditor(user, organization):
|
||||
organization.member_role.members.add(ret)
|
||||
return ret
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def org_member(user, organization):
|
||||
ret = user('org-member', False)
|
||||
organization.member_role.members.add(ret)
|
||||
return ret
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def organizations(instance):
|
||||
def rf(organization_count=1):
|
||||
@@ -258,6 +287,7 @@ def organizations(instance):
|
||||
return orgs
|
||||
return rf
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def group_factory(inventory):
|
||||
def g(name):
|
||||
@@ -267,6 +297,7 @@ def group_factory(inventory):
|
||||
return Group.objects.create(inventory=inventory, name=name)
|
||||
return g
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def hosts(group_factory):
|
||||
group1 = group_factory('group-1')
|
||||
@@ -282,23 +313,28 @@ def hosts(group_factory):
|
||||
return hosts
|
||||
return rf
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def group(inventory):
|
||||
return inventory.groups.create(name='single-group')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inventory_source(group, inventory):
|
||||
return InventorySource.objects.create(name=group.name, group=group,
|
||||
inventory=inventory, source='gce')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inventory_update(inventory_source):
|
||||
return InventoryUpdate.objects.create(inventory_source=inventory_source)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def host(group, inventory):
|
||||
return group.hosts.create(name='single-host', inventory=inventory)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def permissions():
|
||||
return {
|
||||
@@ -340,36 +376,42 @@ def _request(verb):
|
||||
return response
|
||||
return rf
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def post():
|
||||
return _request('post')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def get():
|
||||
return _request('get')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def put():
|
||||
return _request('put')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def patch():
|
||||
return _request('patch')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def delete():
|
||||
return _request('delete')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def head():
|
||||
return _request('head')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def options():
|
||||
return _request('options')
|
||||
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fact_scans(group_factory, fact_ansible_json, fact_packages_json, fact_services_json):
|
||||
group1 = group_factory('group-1')
|
||||
@@ -392,27 +434,33 @@ def fact_scans(group_factory, fact_ansible_json, fact_packages_json, fact_servic
|
||||
return facts
|
||||
return rf
|
||||
|
||||
|
||||
def _fact_json(module_name):
|
||||
current_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
with open('%s/%s.json' % (current_dir, module_name)) as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fact_ansible_json():
|
||||
return _fact_json('ansible')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fact_packages_json():
|
||||
return _fact_json('packages')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fact_services_json():
|
||||
return _fact_json('services')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def permission_inv_read(organization, inventory, team):
|
||||
return Permission.objects.create(inventory=inventory, team=team, permission_type=PERM_INVENTORY_READ)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def job_template(organization):
|
||||
jt = JobTemplate(name='test-job_template')
|
||||
@@ -420,6 +468,7 @@ def job_template(organization):
|
||||
|
||||
return jt
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def job_template_labels(organization, job_template):
|
||||
job_template.labels.create(name="label-1", organization=organization)
|
||||
|
||||
Reference in New Issue
Block a user