mirror of
https://github.com/ansible/awx.git
synced 2026-03-16 00:17:29 -02:30
Fix up flake8 errors
This commit is contained in:
@@ -44,7 +44,7 @@ class BrowsableAPIRenderer(renderers.BrowsableAPIRenderer):
|
|||||||
def get_rendered_html_form(self, data, view, method, request):
|
def get_rendered_html_form(self, data, view, method, request):
|
||||||
# Never show auto-generated form (only raw form).
|
# Never show auto-generated form (only raw form).
|
||||||
obj = getattr(view, 'object', None)
|
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:
|
try:
|
||||||
obj = view.get_object()
|
obj = view.get_object()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class InstanceManager(models.Manager):
|
|||||||
return self.all().count()
|
return self.all().count()
|
||||||
|
|
||||||
def total_capacity(self):
|
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']
|
.aggregate(total_capacity=Sum('capacity'))['total_capacity']
|
||||||
return max(50, sumval)
|
return max(50, sumval)
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ except ImportError:
|
|||||||
|
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
|
|
||||||
from awx.main.models import Instance
|
|
||||||
|
|
||||||
from awx.main.management.commands.update_password import UpdatePassword
|
from awx.main.management.commands.update_password import UpdatePassword
|
||||||
|
|
||||||
def run_command(name, *args, **options):
|
def run_command(name, *args, **options):
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
from awx.main.models import Job, Instance
|
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 django.test.utils import override_settings
|
||||||
|
|
||||||
from datetime import timedelta
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@@ -17,9 +12,9 @@ def test_orphan_unified_job_creation(instance, inventory):
|
|||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_job_capacity_and_with_inactive_node():
|
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
|
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
|
assert Instance.objects.total_capacity() == 100
|
||||||
with override_settings(AWX_ACTIVE_NODE_TIME=0):
|
with override_settings(AWX_ACTIVE_NODE_TIME=0):
|
||||||
assert Instance.objects.total_capacity() < 100
|
assert Instance.objects.total_capacity() < 100
|
||||||
|
|||||||
Reference in New Issue
Block a user