mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 09:07:45 -02:30
Fixing up more pep8 issues
This commit is contained in:
@@ -348,7 +348,7 @@ class HostAccess(BaseAccess):
|
||||
return obj and self.user.can_access(Inventory, 'read', obj.inventory)
|
||||
|
||||
def can_add(self, data):
|
||||
if not data or not 'inventory' in data:
|
||||
if not data or 'inventory' not in data:
|
||||
return False
|
||||
|
||||
# Checks for admin or change permission on inventory.
|
||||
@@ -419,7 +419,7 @@ class GroupAccess(BaseAccess):
|
||||
return obj and self.user.can_access(Inventory, 'read', obj.inventory)
|
||||
|
||||
def can_add(self, data):
|
||||
if not data or not 'inventory' in data:
|
||||
if not data or 'inventory' not in data:
|
||||
return False
|
||||
# Checks for admin or change permission on inventory.
|
||||
inventory_pk = get_pk_from_dict(data, 'inventory')
|
||||
|
||||
@@ -38,8 +38,7 @@ from django.utils.timezone import now
|
||||
|
||||
# AWX
|
||||
from awx.main.constants import CLOUD_PROVIDERS
|
||||
from awx.main.models import * # Job, JobEvent, ProjectUpdate, InventoryUpdate,
|
||||
# Schedule, UnifiedJobTemplate, Instance
|
||||
from awx.main.models import *
|
||||
from awx.main.queue import FifoQueue
|
||||
from awx.main.utils import (get_ansible_version, decrypt_field, update_scm_url,
|
||||
ignore_inventory_computed_fields, emit_websocket_notification,
|
||||
|
||||
@@ -170,8 +170,7 @@ class BaseTestMixin(QueueTestMixin):
|
||||
contact_name='AWX Admin',
|
||||
contact_email='awx@example.com',
|
||||
license_date=int(time.time() + 3600),
|
||||
instance_count=instance_count,
|
||||
)
|
||||
instance_count=instance_count)
|
||||
handle, license_path = tempfile.mkstemp(suffix='.json')
|
||||
os.close(handle)
|
||||
writer.write_file(license_path)
|
||||
@@ -633,6 +632,7 @@ class URI(object):
|
||||
|
||||
def __string__(self):
|
||||
return self.get_uri()
|
||||
|
||||
def __repr__(self):
|
||||
return self.get_uri()
|
||||
|
||||
|
||||
@@ -60,8 +60,7 @@ class InventoryTest(BaseTest):
|
||||
self.perm_read = Permission.objects.create(
|
||||
inventory = self.inventory_b,
|
||||
user = self.other_django_user,
|
||||
permission_type = 'read'
|
||||
)
|
||||
permission_type = 'read')
|
||||
|
||||
def tearDown(self):
|
||||
super(InventoryTest, self).tearDown()
|
||||
@@ -346,8 +345,7 @@ class InventoryTest(BaseTest):
|
||||
edit_perm = Permission.objects.create(
|
||||
user = self.other_django_user,
|
||||
inventory = Inventory.objects.get(pk=inv.pk),
|
||||
permission_type = PERM_INVENTORY_WRITE
|
||||
)
|
||||
permission_type = PERM_INVENTORY_WRITE)
|
||||
host_data3 = self.post(hosts, data=new_host_c, expect=201, auth=self.get_other_credentials())
|
||||
|
||||
# Port should be split out into host variables, other variables kept intact.
|
||||
@@ -1143,15 +1141,15 @@ class InventoryUpdatesTest(BaseTransactionTest):
|
||||
#print inventory_update.result_stdout
|
||||
if should_error:
|
||||
self.assertEqual(inventory_update.status, 'error',
|
||||
inventory_update.result_stdout + \
|
||||
inventory_update.result_stdout +
|
||||
inventory_update.result_traceback)
|
||||
elif should_fail:
|
||||
self.assertEqual(inventory_update.status, 'failed',
|
||||
inventory_update.result_stdout + \
|
||||
inventory_update.result_stdout +
|
||||
inventory_update.result_traceback)
|
||||
elif should_fail is False:
|
||||
self.assertEqual(inventory_update.status, 'successful',
|
||||
inventory_update.result_stdout + \
|
||||
inventory_update.result_stdout +
|
||||
inventory_update.result_traceback)
|
||||
else:
|
||||
pass # If should_fail is None, we don't care.
|
||||
@@ -1673,6 +1671,7 @@ class InventoryUpdatesTest(BaseTransactionTest):
|
||||
return
|
||||
# Print out group/host tree for debugging.
|
||||
print
|
||||
|
||||
def draw_tree(g, d=0):
|
||||
print (' ' * d) + '+ ' + g.name
|
||||
for h in g.hosts.order_by('name'):
|
||||
|
||||
@@ -399,16 +399,14 @@ class BaseJobTestMixin(BaseTestMixin):
|
||||
# Greg and Holly work on east, Greg and iris work on west.
|
||||
self.team_ops_east = self.org_ops.teams.create(
|
||||
name='easterners',
|
||||
created_by=self.user_sue,
|
||||
)
|
||||
created_by=self.user_sue)
|
||||
self.team_ops_east.projects.add(self.proj_prod)
|
||||
self.team_ops_east.projects.add(self.proj_prod_east)
|
||||
self.team_ops_east.users.add(self.user_greg)
|
||||
self.team_ops_east.users.add(self.user_holly)
|
||||
self.team_ops_west = self.org_ops.teams.create(
|
||||
name='westerners',
|
||||
created_by=self.user_sue,
|
||||
)
|
||||
created_by=self.user_sue)
|
||||
self.team_ops_west.projects.add(self.proj_prod)
|
||||
self.team_ops_west.projects.add(self.proj_prod_west)
|
||||
self.team_ops_west.users.add(self.user_greg)
|
||||
|
||||
@@ -47,8 +47,7 @@ class LicenseTests(BaseTest):
|
||||
contact_name='Michael DeHaan',
|
||||
contact_email='michael@ansibleworks.com',
|
||||
license_date=25000, # seconds since epoch
|
||||
instance_count=500
|
||||
)
|
||||
instance_count=500)
|
||||
|
||||
data = writer.get_data()
|
||||
|
||||
@@ -69,12 +68,12 @@ class LicenseTests(BaseTest):
|
||||
assert vdata['available_instances'] == 500
|
||||
assert vdata['current_instances'] == 12
|
||||
assert vdata['free_instances'] == 488
|
||||
assert vdata['date_warning'] == True
|
||||
assert vdata['date_expired'] == True
|
||||
assert vdata['date_warning'] is True
|
||||
assert vdata['date_expired'] is True
|
||||
assert vdata['license_date'] == 25000
|
||||
assert vdata['time_remaining'] < 0
|
||||
assert vdata['valid_key'] == True
|
||||
assert vdata['compliant'] == False
|
||||
assert vdata['valid_key'] is True
|
||||
assert vdata['compliant'] is False
|
||||
|
||||
def test_expired_licenses(self):
|
||||
reader = TaskSerializer()
|
||||
@@ -88,7 +87,7 @@ class LicenseTests(BaseTest):
|
||||
strdata = writer.get_string()
|
||||
vdata = reader.from_string(strdata)
|
||||
|
||||
assert vdata['compliant'] == False
|
||||
assert vdata['compliant'] is False
|
||||
assert vdata['grace_period_remaining'] < 0
|
||||
|
||||
writer = TaskEngager(
|
||||
@@ -101,7 +100,7 @@ class LicenseTests(BaseTest):
|
||||
strdata = writer.get_string()
|
||||
vdata = reader.from_string(strdata)
|
||||
|
||||
assert vdata['compliant'] == False
|
||||
assert vdata['compliant'] is False
|
||||
assert vdata['grace_period_remaining'] < 0
|
||||
|
||||
writer = TaskEngager(
|
||||
@@ -114,5 +113,5 @@ class LicenseTests(BaseTest):
|
||||
strdata = writer.get_string()
|
||||
vdata = reader.from_string(strdata)
|
||||
|
||||
assert vdata['compliant'] == False
|
||||
assert vdata['compliant'] is False
|
||||
assert vdata['grace_period_remaining'] > 0
|
||||
|
||||
@@ -932,6 +932,7 @@ class ProjectUpdatesTest(BaseTransactionTest):
|
||||
|
||||
# FIXME: Add some invalid URLs.
|
||||
]
|
||||
|
||||
def is_exception(e):
|
||||
return bool(isinstance(e, Exception) or
|
||||
(isinstance(e, type) and issubclass(e, Exception)))
|
||||
@@ -1320,8 +1321,7 @@ class ProjectUpdatesTest(BaseTransactionTest):
|
||||
scm_password=scm_password,
|
||||
)
|
||||
should_error = bool('github.com' in scm_url and scm_username != 'git')
|
||||
self.check_project_update(project2, should_fail=None)#,
|
||||
#should_error=should_error)
|
||||
self.check_project_update(project2, should_fail=None) # , should_error=should_error)
|
||||
|
||||
def test_scm_key_unlock_on_project_update(self):
|
||||
scm_url = 'git@github.com:ansible/ansible.github.com.git'
|
||||
@@ -1630,8 +1630,7 @@ class ProjectUpdatesTest(BaseTransactionTest):
|
||||
name='my public git project over https',
|
||||
scm_type='git',
|
||||
scm_url=scm_url,
|
||||
scm_update_on_launch=True,
|
||||
)
|
||||
scm_update_on_launch=True)
|
||||
# First update triggered by saving a new project with SCM.
|
||||
self.assertEqual(self.project.project_updates.count(), 1)
|
||||
self.check_project_update(self.project)
|
||||
|
||||
@@ -36,8 +36,7 @@ GOOD_SCHEDULES = ["DTSTART:20500331T055000Z RRULE:FREQ=MINUTELY;INTERVAL=10;COUN
|
||||
"DTSTART:20140331T075000Z RRULE:FREQ=YEARLY;INTERVAL=1;BYSETPOS=-1;BYMONTH=8;BYDAY=SU",
|
||||
"DTSTART:20140331T075000Z RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20230401T075000Z;BYDAY=MO,WE,FR",
|
||||
"DTSTART:20140331T075000Z RRULE:FREQ=HOURLY;INTERVAL=1;UNTIL=20230610T075000Z",
|
||||
"DTSTART:20140411T040000Z RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20140411T040000Z;BYDAY=WE",
|
||||
]
|
||||
"DTSTART:20140411T040000Z RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20140411T040000Z;BYDAY=WE"]
|
||||
BAD_SCHEDULES = ["", "DTSTART:20140331T055000 RRULE:FREQ=MINUTELY;INTERVAL=10;COUNT=5",
|
||||
"RRULE:FREQ=MINUTELY;INTERVAL=10;COUNT=5",
|
||||
"FREQ=MINUTELY;INTERVAL=10;COUNT=5",
|
||||
@@ -51,8 +50,7 @@ BAD_SCHEDULES = ["", "DTSTART:20140331T055000 RRULE:FREQ=MINUTELY;INTERVAL=10;CO
|
||||
"DTSTART:20140331T055000Z RRULE:FREQ=YEARLY;BYYEARDAY=120;INTERVAL=1",
|
||||
"DTSTART:20140331T055000Z RRULE:FREQ=YEARLY;BYWEEKNO=10;INTERVAL=1",
|
||||
"DTSTART:20140331T055000Z RRULE:FREQ=HOURLY;INTERVAL=1 DTSTART:20140331T055000Z RRULE:FREQ=HOURLY;INTERVAL=1",
|
||||
"DTSTART:20140331T055000Z RRULE:FREQ=HOURLY;INTERVAL=1 RRULE:FREQ=HOURLY;INTERVAL=1",
|
||||
]
|
||||
"DTSTART:20140331T055000Z RRULE:FREQ=HOURLY;INTERVAL=1 RRULE:FREQ=HOURLY;INTERVAL=1"]
|
||||
class ScheduleTest(BaseTest):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -52,7 +52,7 @@ class BaseScriptTest(BaseLiveServerTest):
|
||||
pargs = [name]
|
||||
for k,v in options.items():
|
||||
pargs.append('%s%s' % ('-' if len(k) == 1 else '--', k))
|
||||
if not v is True:
|
||||
if v is not True:
|
||||
pargs.append(str(v))
|
||||
for arg in args:
|
||||
pargs.append(str(arg))
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
# W391 - Blank line at end of file
|
||||
# W293 - Blank line contains whitespace
|
||||
ignore=E201,E203,E221,E225,E231,E241,E251,E261,E265,E302,E303,E501,W291,W391,W293
|
||||
exclude=awx/lib/site-packages,awx/ui,awx/api/urls.py,awx/main/migrations
|
||||
exclude=awx/lib/site-packages,awx/ui,awx/api/urls.py,awx/main/migrations,awx/main/tests/data
|
||||
|
||||
Reference in New Issue
Block a user