mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 15:21:13 +03:00
Fix up flake8 errors
This commit is contained in:
parent
75c364930f
commit
30984a3a79
@ -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:
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user