Esempio n. 1
0
def test_publish_failure(monkeypatch):
    mock_connection(monkeypatch)

    connection = Connection(connection_params)
    # publish should fail if we do not perform connection.connect()
    with pytest.raises(Exception):
        connection.publish(exchange="exchange", key="key", msg="message")
def test_publish(monkeypatch):
    mock_connection(monkeypatch)

    connection = Connection(connection_params)
    connection.connect()
    connection.publish(exchange="exchange", key="key", msg="message")
    assert (published_message == json.dumps("message"))
    connection.disconnect()
Esempio n. 3
0
def test_publish(monkeypatch):
    mock_connection(monkeypatch)

    connection = Connection(connection_params)
    assert connection._params == {"load_message": True, "prefetch_count": 1, "stream_contents": False}
    connection.connect()
    connection.publish(exchange="exchange", key="key", msg="message")
    assert(published_message == json.dumps("message"))
    connection.disconnect()
Esempio n. 4
0
def test_publish_failure(monkeypatch):
    # Test publish failure
    mock_connection(monkeypatch)

    connection = Connection(connection_params)
    queue = {
        "name": "name",
        "key": "key"
    }
    with pytest.raises(Exception):
        connection.publish(queue, "key", "message")
Esempio n. 5
0
def test_publish(monkeypatch):
    # Test publish message
    mock_connection(monkeypatch)

    connection = Connection(connection_params)
    connection.connect()
    queue = {
        "exchange": "exchange",
        "name": "name",
        "key": "key"
    }
    connection.publish(queue, "key", "message")
    assert(published_message == json.dumps("message"))
    connection.disconnect()