mirror of
https://github.com/ansible/awx.git
synced 2026-06-22 15:17:44 -02:30
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user