예제 #1
0
def test_basic_worker():
    channel = InputOutputEndpoint()
    w = Worker(channel, identity_work_method)
    w.start()

    channel.push("TEST")

    assert channel.pull() == [
        "TEST",
    ]
    assert channel._acks == [
        True,
    ]
예제 #2
0
def test_invalid_payload_sends_error_and_nacks():

    channel = InputOutputEndpoint()
    w = Worker(channel, identity_work_method, all_payloads_are_invalid)
    w.start()

    channel.push("TEST")

    assert channel.pull() == [
        invalid_payload_error,
    ]
    assert channel._acks == [
        False,
    ]
예제 #3
0
def test_error_field_with_no_error():
    channel = InputOutputEndpoint()
    w = Worker(channel, work_method)
    w.start()

    error_payload = {
        "error": {},
    }
    channel.push(error_payload)

    assert channel.pull() == [
        "WORKED",
    ]
    assert channel._acks == [
        True,
    ]
예제 #4
0
def test_forward_payload_error():
    channel = InputOutputEndpoint()
    w = Worker(channel, work_method)
    w.start()

    error_payload = {
        "error": "Some error",
    }
    channel.push(error_payload)

    assert channel.pull() == [
        error_payload,
    ]
    assert channel._acks == [
        True,
    ]