Ejemplo n.º 1
0
def test_is_not_done():
    mock_cmd_ch = Mock()
    job_id = "some_job_id"
    cmd_id = "some_command_id"
    stand_in_status = CommandStatus(job_id, cmd_id)
    stand_in_status.state = CommandState.ERROR
    mock_cmd_ch.get_command.return_value = stand_in_status
    under_test = CommandHandler(mock_cmd_ch, cmd_id)
    with pytest.raises(RuntimeError):
        under_test.is_done()
    assert mock_cmd_ch.get_command.call_count >= 1
Ejemplo n.º 2
0
def test_has_timed_out():
    mock_cmd_ch = Mock()
    job_id = "some_job_id"
    cmd_id = "some_command_id"
    stand_in_status = CommandStatus(job_id, cmd_id)
    stand_in_status.state = CommandState.TIMEOUT_RESPONSE
    mock_cmd_ch.get_command.return_value = stand_in_status
    under_test = CommandHandler(mock_cmd_ch, cmd_id)
    with pytest.raises(RuntimeError):
        under_test.is_done()
    mock_cmd_ch.get_command.assert_called_once_with(cmd_id)
Ejemplo n.º 3
0
def test_is_done():
    mock_cmd_ch = Mock()
    job_id = "some_job_id"
    cmd_id = "some_command_id"
    stand_in_status = CommandStatus(job_id, cmd_id)
    stand_in_status.state = CommandState.SUCCESS
    mock_cmd_ch.get_command.return_value = stand_in_status
    under_test = CommandHandler(mock_cmd_ch, cmd_id)
    assert under_test.is_done()
    mock_cmd_ch.get_command.assert_called_once_with(cmd_id)