コード例 #1
0
def test_update_command_status():
    under_test = CommandChannel("localhost:42/some_topic")
    job_id = "some_other_id"
    command_id = "some_id"
    new_status = CommandStatus(job_id, command_id)
    assert len(under_test.list_commands()) == 0
    assert under_test.get_command(command_id) is None
    under_test.status_queue.put(new_status)
    under_test.update_workers()
    assert len(under_test.list_commands()) == 1
    assert under_test.get_command(command_id).command_id == command_id
    under_test.stop_thread()
    del under_test
コード例 #2
0
def test_add_command_id():
    under_test = CommandChannel("localhost:42/some_topic")
    assert len(under_test.list_commands()) == 0
    command_id_1 = "some_command_id_1"
    job_id = "some_job_id"
    assert under_test.get_command(command_id_1) is None
    under_test.add_command_id(job_id, command_id_1)
    assert len(under_test.list_commands()) == 1
    assert under_test.get_command(command_id_1).command_id == command_id_1
    command_id_2 = "some_command_id_2"
    assert under_test.get_command(command_id_2) is None
    under_test.add_command_id(job_id, command_id_2)
    assert len(under_test.list_commands()) == 2
    assert under_test.get_command(command_id_2).command_id == command_id_2
    under_test.stop_thread()