Example #1
0
def test_ad_hoc_event_websocket_notifications(emit):
    ahc = AdHocCommand(id=123)
    ahc.save()
    AdHocCommandEvent.create_from_data(ad_hoc_command_id=ahc.pk)
    assert len(emit.call_args_list) == 1
    topic, payload = emit.call_args_list[0][0]
    assert topic == 'ad_hoc_command_events-123'
    assert payload['ad_hoc_command'] == 123
Example #2
0
def test_ad_hoc_events_sublist_truncation(get, organization_factory, job_template_factory, truncate, expected):
    objs = organization_factory("org", superusers=['admin'])
    adhoc = AdHocCommand()
    adhoc.save()
    AdHocCommandEvent.create_from_data(ad_hoc_command_id=adhoc.pk, uuid='abc123', event='runner_on_start', stdout='a' * 1025, job_created=adhoc.created).save()

    url = reverse('api:ad_hoc_command_ad_hoc_command_events_list', kwargs={'pk': adhoc.pk})
    if not truncate:
        url += '?no_truncate=1'

    response = get(url, user=objs.superusers.admin, expect=200)
    assert (len(response.data['results'][0]['stdout']) == 1025) == expected