From 30984a3a7940a0ca33371ce304d0069e4788bbc3 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Thu, 10 Nov 2016 13:07:33 -0500 Subject: [PATCH] Fix up flake8 errors --- awx/api/renderers.py | 2 +- awx/main/managers.py | 2 +- awx/main/tests/functional/commands/test_commands.py | 2 -- awx/main/tests/functional/test_jobs.py | 9 ++------- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/awx/api/renderers.py b/awx/api/renderers.py index a86865860a..9f3d17470e 100644 --- a/awx/api/renderers.py +++ b/awx/api/renderers.py @@ -44,7 +44,7 @@ class BrowsableAPIRenderer(renderers.BrowsableAPIRenderer): def get_rendered_html_form(self, data, view, method, request): # Never show auto-generated form (only raw form). obj = getattr(view, 'object', None) - if obj is None and hasattr(view, 'get_object') and hasattr(view, 'retrieve'):# and view.check_permissions(): + if obj is None and hasattr(view, 'get_object') and hasattr(view, 'retrieve'): try: obj = view.get_object() except Exception: diff --git a/awx/main/managers.py b/awx/main/managers.py index 9a994aad9f..5fad1e11c8 100644 --- a/awx/main/managers.py +++ b/awx/main/managers.py @@ -44,7 +44,7 @@ class InstanceManager(models.Manager): return self.all().count() def total_capacity(self): - sumval = self.filter(modified__gte=now()-timedelta(seconds=settings.AWX_ACTIVE_NODE_TIME)) \ + sumval = self.filter(modified__gte=now() - timedelta(seconds=settings.AWX_ACTIVE_NODE_TIME)) \ .aggregate(total_capacity=Sum('capacity'))['total_capacity'] return max(50, sumval) diff --git a/awx/main/tests/functional/commands/test_commands.py b/awx/main/tests/functional/commands/test_commands.py index 024b17a0ab..d3f4e6b949 100644 --- a/awx/main/tests/functional/commands/test_commands.py +++ b/awx/main/tests/functional/commands/test_commands.py @@ -8,8 +8,6 @@ except ImportError: from django.core.management import call_command -from awx.main.models import Instance - from awx.main.management.commands.update_password import UpdatePassword def run_command(name, *args, **options): diff --git a/awx/main/tests/functional/test_jobs.py b/awx/main/tests/functional/test_jobs.py index c5469fbe45..8a44b622a8 100644 --- a/awx/main/tests/functional/test_jobs.py +++ b/awx/main/tests/functional/test_jobs.py @@ -1,10 +1,5 @@ from awx.main.models import Job, Instance - -from django.utils import timezone -from django.conf import settings from django.test.utils import override_settings - -from datetime import timedelta import pytest @pytest.mark.django_db @@ -17,9 +12,9 @@ def test_orphan_unified_job_creation(instance, inventory): @pytest.mark.django_db def test_job_capacity_and_with_inactive_node(): - i = Instance.objects.create(hostname='test-1', capacity=50) + Instance.objects.create(hostname='test-1', capacity=50) assert Instance.objects.total_capacity() == 50 - i2 = Instance.objects.create(hostname='test-2', capacity=50) + Instance.objects.create(hostname='test-2', capacity=50) assert Instance.objects.total_capacity() == 100 with override_settings(AWX_ACTIVE_NODE_TIME=0): assert Instance.objects.total_capacity() < 100