From b4193e231e57f9c4e1786e9b4e3d8e392967c168 Mon Sep 17 00:00:00 2001 From: John Chilton <jmchilton@gmail.com> Date: Sun, 10 Apr 2016 16:22:24 -0400 Subject: [PATCH] Improve tests. - Docstrings for AMQP tests. - Skip curl tests if pycurl is unavailable. - Time the AMQP test in case this is what is causing Travis to hang. --- test/amqp_test.py | 12 +++++++++++- test/client_transport_test.py | 7 ++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/test/amqp_test.py b/test/amqp_test.py index d2206076..955629a5 100644 --- a/test/amqp_test.py +++ b/test/amqp_test.py @@ -1,14 +1,21 @@ +"""Tests for ``pulsar.client.amqp_exchange``.""" import time import threading -from .test_utils import skip_unless_module from pulsar.client import amqp_exchange +from .test_utils import ( + skip_unless_module, + timed, +) + TEST_CONNECTION = "memory://test_amqp" @skip_unless_module("kombu") +@timed(15) def test_amqp(): + """Test the client PulsarExchange abstraction with an in-memory connection.""" manager1_exchange = amqp_exchange.PulsarExchange(TEST_CONNECTION, "manager_test") manager3_exchange = amqp_exchange.PulsarExchange(TEST_CONNECTION, "manager3_test") manager2_exchange = amqp_exchange.PulsarExchange(TEST_CONNECTION, "manager2_test") @@ -56,3 +63,6 @@ class TestThread(threading.Thread): raise AssertionError(msg) self.join(2) + + +__all__ = ["test_amqp"] diff --git a/test/client_transport_test.py b/test/client_transport_test.py index c3a2cb6d..9c76042f 100644 --- a/test/client_transport_test.py +++ b/test/client_transport_test.py @@ -1,18 +1,21 @@ import os +from tempfile import NamedTemporaryFile from pulsar.client.transport.standard import Urllib2Transport from pulsar.client.transport.curl import PycurlTransport from pulsar.client.transport.curl import post_file from pulsar.client.transport.curl import get_file from pulsar.client.transport import get_transport -from tempfile import NamedTemporaryFile + from .test_utils import files_server +from .test_utils import skip_unless_module def test_urllib_transports(): _test_transport(Urllib2Transport()) +@skip_unless_module("pycurl") def test_pycurl_transport(): _test_transport(PycurlTransport()) @@ -37,6 +40,7 @@ def _test_transport(transport): assert open(output_path, 'r').read().find("Test123") >= 0 +@skip_unless_module("pycurl") def test_curl_put_get(): with files_server() as (server, directory): server_url = server.application_url @@ -74,6 +78,7 @@ def test_curl_status_code(): assert exception_raised +@skip_unless_module("pycurl") def test_curl_problems(): with files_server() as (server, directory): server_url = server.application_url -- GitLab