added SkipTest for cname tests if dnspython is not installed
This commit is contained in:
@@ -23,7 +23,7 @@ from swift.common.utils import cache_from_env
|
|||||||
def lookup_cname(domain): # pragma: no cover
|
def lookup_cname(domain): # pragma: no cover
|
||||||
"""
|
"""
|
||||||
Given a domain, returns it's DNS CNAME mapping and DNS ttl.
|
Given a domain, returns it's DNS CNAME mapping and DNS ttl.
|
||||||
|
|
||||||
:param domain: domain to query on
|
:param domain: domain to query on
|
||||||
:returns: (ttl, result)
|
:returns: (ttl, result)
|
||||||
"""
|
"""
|
||||||
|
@@ -14,11 +14,16 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
from nose import SkipTest
|
||||||
|
|
||||||
from webob import Request
|
from webob import Request
|
||||||
|
|
||||||
from swift.common.middleware import cname_lookup
|
try:
|
||||||
|
# this test requires the dnspython package to be installed
|
||||||
|
from swift.common.middleware import cname_lookup
|
||||||
|
skip = False
|
||||||
|
except ImportError:
|
||||||
|
skip = True
|
||||||
|
|
||||||
class FakeApp(object):
|
class FakeApp(object):
|
||||||
|
|
||||||
@@ -33,11 +38,13 @@ def start_response(*args):
|
|||||||
class TestCNAMELookup(unittest.TestCase):
|
class TestCNAMELookup(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
if skip:
|
||||||
|
raise SkipTest
|
||||||
self.app = cname_lookup.CNAMELookupMiddleware(FakeApp(),
|
self.app = cname_lookup.CNAMELookupMiddleware(FakeApp(),
|
||||||
{'lookup_depth': 2})
|
{'lookup_depth': 2})
|
||||||
|
|
||||||
def test_passthrough(self):
|
def test_passthrough(self):
|
||||||
|
|
||||||
def my_lookup(d):
|
def my_lookup(d):
|
||||||
return 0, d
|
return 0, d
|
||||||
cname_lookup.lookup_cname = my_lookup
|
cname_lookup.lookup_cname = my_lookup
|
||||||
|
Reference in New Issue
Block a user