Esempio n. 1
0
def test_get_messages_exception_thrown_out(get_mock_boto):
    fake_conn = FakeConn()
    fake_queue = FakeQueue()
    fake_conn.set_queue(fake_queue)
    fake_queue.exception = True  # set it to throw boto error
    mock_obj = get_mock_boto
    mock_obj.return_value = fake_conn
    sqs = SQSWrapper("some-queue", None)
    with pytest.raises(BotoServerError):
        sqs.get_messages_from_queue()
    mock_obj.assert_called_once_with('us-west-2', **get_test_creds())
Esempio n. 2
0
def test_get_messages_successful_case_no_errors(get_mock_boto):
    fake_conn = FakeConn()
    fake_queue = FakeQueue()
    fake_conn.set_queue(fake_queue)
    fake_queue.set_messages([object()])

    mock_obj = get_mock_boto
    mock_obj.return_value = fake_conn
    sqs = SQSWrapper("some-queue", None)
    ret = sqs.get_messages_from_queue()
    assert len(ret) == 1, "Expected 1 message from sqs queue"
    mock_obj.assert_called_once_with('us-west-2', **get_test_creds())