fix tests, add pagination tests

* job_created is a fake field as far as Django is concerned. Under the
hood, in postgres, this is the partition key so it is real. sqlite
doesn't support partitioning so we need to fake some things.
Specifically, we need to remove job_created from being auto-added to
get_event_queryset()
* Add pagination tests for <unified_job_name>/<id>/<job_events>?limit=x
endpoint to make sure the paginator is wired up.
This commit is contained in:
Chris Meyers
2021-05-26 10:53:14 -04:00
committed by Jim Ladd
parent b648957c8e
commit ffbbcd2bf6
3 changed files with 62 additions and 2 deletions

View File

@@ -134,7 +134,8 @@ class TestJobDetailSerializerGetHostStatusCountFields(object):
)
mock_qs = namedtuple('mock_qs', ['get'])(mocker.MagicMock(return_value=mock_event))
job.job_events.only = mocker.MagicMock(return_value=mock_qs)
only = mocker.MagicMock(return_value=mock_qs)
job.get_event_queryset = lambda *args, **kwargs: mocker.MagicMock(only=only)
serializer = JobDetailSerializer()
host_status_counts = serializer.get_host_status_counts(job)
@@ -142,7 +143,7 @@ class TestJobDetailSerializerGetHostStatusCountFields(object):
assert host_status_counts == {'ok': 1, 'changed': 1, 'dark': 2}
def test_host_status_counts_is_empty_dict_without_stats_event(self, job):
job.job_events = JobEvent.objects.none()
job.get_event_queryset = lambda *args, **kwargs: JobEvent.objects.none()
serializer = JobDetailSerializer()
host_status_counts = serializer.get_host_status_counts(job)