Example #1
0
def test_set_message():
    under_test1 = CommandStatus("job_id1", "command_id1")
    last_update = under_test1.last_update
    test_msg = "some test message"
    assert under_test1.message == ""
    under_test1.message = test_msg
    assert under_test1.message == test_msg
    assert under_test1.last_update != last_update
Example #2
0
def test_update_message():
    under_test1 = CommandStatus("job_id1", "command_id1")
    under_test2 = CommandStatus("job_id1", "command_id1")
    test_msg = "some test message"
    under_test1.message = test_msg
    assert under_test2.message == ""
    under_test2.update_status(under_test1)  # No exception
    assert under_test2.message == test_msg
Example #3
0
def test_get_error_with_id():
    mock_cmd_ch = Mock()
    job_id = "some_job_id"
    cmd_id = "some_command_id"
    message_string = "some message"
    stand_in_status = CommandStatus(job_id, cmd_id)
    stand_in_status.message = message_string
    mock_cmd_ch.get_command.return_value = stand_in_status
    under_test = CommandHandler(mock_cmd_ch, cmd_id)
    assert under_test.get_message() == message_string
    mock_cmd_ch.get_command.assert_called_once_with(cmd_id)