Example #1
0
def test_process_msg_stop():
    stop_msg = serialise_stop("job id")
    status_queue = Queue()
    under_test = InThreadStatusTracker(status_queue)
    under_test.process_set_stop_time = Mock()
    under_test.process_message(stop_msg)
    under_test.process_set_stop_time.assert_called_once_with(
        deserialise_stop(stop_msg))
Example #2
0
def test_process_set_stop_time():
    status_queue = Queue()
    under_test = InThreadStatusTracker(status_queue)
    job_id = "some_job_id"
    service_id = "some_service_id"
    command_id = "some command id"
    stop = RunStopInfo(
        job_id=job_id,
        stop_time=datetime.now(),
        run_name="run_name",
        service_id=service_id,
        command_id=command_id,
    )
    assert status_queue.empty()
    now = datetime.now()
    under_test.process_set_stop_time(stop)
    under_test.send_status_if_updated(now)
    assert not status_queue.empty()
    command_status = status_queue.get()
    assert status_queue.empty()
    assert command_status.state == CommandState.WAITING_RESPONSE