def test_send():
    """
    MessageSenderMixin._send() Test plan:
        -ensure events named transaction raise error
        -ensure callback is set on success
        -ensure that a response is received
    """

    test_payload = {"item": "shoe"}

    httpretty.register_uri(
        httpretty.POST,
        "https://www.hpit-project.org/message",
        body='{"message_id":"4"}',
    )

    subject = MessageSenderMixin()

    subject.send.when.called_with(
        "transaction", test_payload,
        None).should.throw(InvalidMessageNameException)

    response = subject.send("test_event", test_payload, send_callback)
    subject.response_callbacks["4"].should.equal(globals()["send_callback"])

    response.should.equal({"message_id": "4"})
def test_send_transaction():
    """
    MessageSenderMixin._send_transaction() Test plan:
        -ensure callback is set on success
        -ensure that a response is received
    """
    
    test_payload = {"item":"shoe"}
    
    httpretty.register_uri(httpretty.POST,"https://www.hpit-project.org/message",
                            body='{"message_id":"4"}',
                            )
    
    subject = MessageSenderMixin()
    
    response = subject.send("test_event",test_payload,send_callback)
    subject.response_callbacks["4"].should.equal(globals()["send_callback"])
    
    response.should.equal({"message_id":"4"})
def test_send_transaction():
    """
    MessageSenderMixin._send_transaction() Test plan:
        -ensure callback is set on success
        -ensure that a response is received
    """

    test_payload = {"item": "shoe"}

    httpretty.register_uri(
        httpretty.POST,
        "https://www.hpit-project.org/message",
        body='{"message_id":"4"}',
    )

    subject = MessageSenderMixin()

    response = subject.send("test_event", test_payload, send_callback)
    subject.response_callbacks["4"].should.equal(globals()["send_callback"])

    response.should.equal({"message_id": "4"})
def test_send():
    """
    MessageSenderMixin._send() Test plan:
        -ensure events named transaction raise error
        -ensure callback is set on success
        -ensure that a response is received
    """
    
    test_payload = {"item":"shoe"}
    
    httpretty.register_uri(httpretty.POST,"https://www.hpit-project.org/message",
                            body='{"message_id":"4"}',
                            )
    
    subject = MessageSenderMixin()
    
    subject.send.when.called_with("transaction",test_payload,None).should.throw(InvalidMessageNameException)
    
    response = subject.send("test_event",test_payload,send_callback)
    subject.response_callbacks["4"].should.equal(globals()["send_callback"])
    
    response.should.equal({"message_id":"4"})