mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -03:30
flake8 cleanup
This commit is contained in:
parent
bb5c7a98f3
commit
5c1d2a6f0b
@ -5,14 +5,11 @@
|
||||
import logging
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.timezone import now
|
||||
|
||||
# Django REST Framework
|
||||
from rest_framework.exceptions import PermissionDenied
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.renderers import JSONRenderer, StaticHTMLRenderer
|
||||
from rest_framework.renderers import JSONRenderer
|
||||
|
||||
# AWX
|
||||
# from awx.main.analytics import collectors
|
||||
@ -23,15 +20,10 @@ from awx.api.generics import (
|
||||
APIView,
|
||||
)
|
||||
|
||||
from awx.api.serializers import (
|
||||
InventorySerializer,
|
||||
ActivityStreamSerializer,
|
||||
)
|
||||
|
||||
logger = logging.getLogger('awx.main.analytics')
|
||||
|
||||
|
||||
|
||||
class MetricsView(APIView):
|
||||
|
||||
view_name = _('Metrics')
|
||||
|
||||
@ -158,15 +158,16 @@ def instance_info(since):
|
||||
instances = models.Instance.objects.values_list('hostname').annotate().values(
|
||||
'uuid', 'version', 'capacity', 'cpu', 'memory', 'managed_by_policy', 'hostname', 'last_isolated_check', 'enabled')
|
||||
for instance in instances:
|
||||
instance_info = {'uuid': instance['uuid'],
|
||||
'version': instance['version'],
|
||||
'capacity': instance['capacity'],
|
||||
'cpu': instance['cpu'],
|
||||
'memory': instance['memory'],
|
||||
'managed_by_policy': instance['managed_by_policy'],
|
||||
'last_isolated_check': instance['last_isolated_check'],
|
||||
'enabled': instance['enabled']
|
||||
}
|
||||
instance_info = {
|
||||
'uuid': instance['uuid'],
|
||||
'version': instance['version'],
|
||||
'capacity': instance['capacity'],
|
||||
'cpu': instance['cpu'],
|
||||
'memory': instance['memory'],
|
||||
'managed_by_policy': instance['managed_by_policy'],
|
||||
'last_isolated_check': instance['last_isolated_check'],
|
||||
'enabled': instance['enabled']
|
||||
}
|
||||
info[instance['uuid']] = instance_info
|
||||
return info
|
||||
|
||||
|
||||
@ -27,15 +27,16 @@ EXPECTED_VALUES = {
|
||||
'awx_instance_memory':0.0,
|
||||
'awx_instance_info':1.0,
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_metrics_counts(organization_factory, job_template_factory,
|
||||
workflow_job_template_factory):
|
||||
|
||||
|
||||
def test_metrics_counts(organization_factory, job_template_factory, workflow_job_template_factory):
|
||||
objs = organization_factory('org', superusers=['admin'])
|
||||
jt = job_template_factory('test', organization=objs.organization,
|
||||
inventory='test_inv', project='test_project',
|
||||
credential='test_cred')
|
||||
jt = job_template_factory(
|
||||
'test', organization=objs.organization,
|
||||
inventory='test_inv', project='test_project',
|
||||
credential='test_cred'
|
||||
)
|
||||
workflow_job_template_factory('test')
|
||||
models.Team(organization=objs.organization).save()
|
||||
models.Host(inventory=jt.inventory).save()
|
||||
@ -52,4 +53,4 @@ def test_metrics_counts(organization_factory, job_template_factory,
|
||||
for sample in gauge.samples:
|
||||
# name, label, value, timestamp, exemplar
|
||||
name, _, value, _, _ = sample
|
||||
assert EXPECTED_VALUES[name] == value
|
||||
assert EXPECTED_VALUES[name] == value
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user