mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
added fact view tests
* Add related link from host to fact_versions * Add related link from fact_versions to fact_view
This commit is contained in:
@@ -1037,12 +1037,17 @@ class HostFactVersionsList(MongoListAPIView):
|
||||
if from_spec is not None:
|
||||
from_actual = dateutil.parser.parse(from_spec)
|
||||
kv['timestamp__gt'] = from_actual
|
||||
if from_spec is not None and to_spec is not None:
|
||||
if to_spec is not None:
|
||||
to_actual = dateutil.parser.parse(to_spec)
|
||||
kv['timestamp__lte'] = to_actual
|
||||
|
||||
return FactVersion.objects.filter(**kv).order_by("-timestamp")
|
||||
|
||||
def list(self, *args, **kwargs):
|
||||
queryset = self.get_queryset() or []
|
||||
serializer = FactVersionSerializer(queryset, many=True, context=dict(host_obj=self.get_parent_object()))
|
||||
return Response(dict(results=serializer.data))
|
||||
|
||||
class HostSingleFactView(MongoAPIView):
|
||||
|
||||
model = Fact
|
||||
@@ -1062,7 +1067,7 @@ class HostSingleFactView(MongoAPIView):
|
||||
datetime_actual = dateutil.parser.parse(datetime_spec) if datetime_spec is not None else now()
|
||||
host_obj = self.get_parent_object()
|
||||
fact_data = Fact.get_single_facts([host_obj.name], fact_key, fact_value, datetime_actual, module_spec)
|
||||
return Response(FactSerializer(fact_data).data if fact_data is not None else {})
|
||||
return Response(FactSerializer(fact_data, context=dict(host_obj=host_obj)).data if fact_data is not None else {})
|
||||
|
||||
class HostFactCompareView(MongoAPIView):
|
||||
|
||||
@@ -1082,7 +1087,6 @@ class HostFactCompareView(MongoAPIView):
|
||||
|
||||
return Response(host_data)
|
||||
|
||||
|
||||
class GroupList(ListCreateAPIView):
|
||||
|
||||
model = Group
|
||||
|
||||
Reference in New Issue
Block a user