def test_system_job_event_websocket_notifications(emit, inventory): j = SystemJob(id=123) j.save() SystemJobEvent.create_from_data(system_job_id=j.pk) assert len(emit.call_args_list) == 1 topic, payload = emit.call_args_list[0][0] assert topic == 'system_job_events-123' assert payload['system_job'] == 123
def test_text_stdout_from_system_job_events(sqlite_copy_expert, get, admin): job = SystemJob() job.save() for i in range(3): SystemJobEvent(system_job=job, stdout='Testing {}\n'.format(i), start_line=i).save() url = reverse('api:system_job_detail', kwargs={'pk': job.pk}) response = get(url, user=admin, expect=200) assert response.data['result_stdout'].splitlines() == ['Testing %d' % i for i in range(3)]
def test_text_stdout_with_max_stdout(sqlite_copy_expert, get, admin): job = SystemJob() job.save() total_bytes = settings.STDOUT_MAX_BYTES_DISPLAY + 1 large_stdout = 'X' * total_bytes SystemJobEvent(system_job=job, stdout=large_stdout, start_line=0).save() url = reverse('api:system_job_detail', kwargs={'pk': job.pk}) response = get(url, user=admin, expect=200) assert response.data['result_stdout'] == ( 'Standard Output too large to display ({actual} bytes), only download ' 'supported for sizes over {max} bytes.'.format( actual=total_bytes, max=settings.STDOUT_MAX_BYTES_DISPLAY))