[mapproxy] 11/28: Run tests as part of the build.

Bas Couwenberg sebastic at debian.org
Wed Jul 27 00:32:57 UTC 2016


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository mapproxy.

commit b5584bf8eba6a021d051e69f7b3adafbc071d3da
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Mon Jul 25 21:37:33 2016 +0200

    Run tests as part of the build.
    
    Changes:
    - Override dh_auto_test to ignore test failures
    - Add pyton{,3}-{lxml,nose,requests,shapely,webtest,yaml} to build dependencies
    - Add patch to skip tests that require network
    
    Fix test.
---
 debian/changelog                   |   4 +
 debian/control                     |  14 +-
 debian/patches/offline-tests.patch | 299 +++++++++++++++++++++++++++++++++++++
 debian/patches/series              |   1 +
 debian/rules                       |   4 +-
 5 files changed, 320 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 3f2a7cb..cdfbbe5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,10 @@ mapproxy (1.8.2-1) UNRELEASED; urgency=medium
   * Rewrite package description with a proper synopsis.
   * Add gbp.conf to use pristine-tar by default.
   * Also build module for Python 3.
+  * Run tests as part of the build, changes:
+    - Override dh_auto_test to ignore test failures
+    - Add pyton{,3}-{lxml,nose,requests,shapely,webtest,yaml} to Build-Depends
+    - Add patch to skip tests that require network
 
  -- Bas Couwenberg <sebastic at debian.org>  Mon, 25 Jul 2016 18:53:14 +0200
 
diff --git a/debian/control b/debian/control
index 0f842f9..cec229d 100644
--- a/debian/control
+++ b/debian/control
@@ -8,13 +8,25 @@ Build-Depends: debhelper (>= 9),
                libgdal-dev,
                libproj-dev,
                python-all,
+               python-lxml,
+               python-nose,
                python-pil,
                python-pkg-resources,
+               python-requests,
                python-setuptools,
+               python-shapely,
+               python-webtest,
+               python-yaml,
                python3-all,
+               python3-lxml,
+               python3-nose,
                python3-pil,
                python3-pkg-resources,
-               python3-setuptools
+               python3-requests,
+               python3-setuptools,
+               python3-shapely,
+               python3-webtest,
+               python3-yaml
 Standards-Version: 3.9.6
 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-grass/mapproxy.git
 Vcs-Git: https://anonscm.debian.org/git/pkg-grass/mapproxy.git
diff --git a/debian/patches/offline-tests.patch b/debian/patches/offline-tests.patch
new file mode 100644
index 0000000..cf7550e
--- /dev/null
+++ b/debian/patches/offline-tests.patch
@@ -0,0 +1,299 @@
+Description: Disable tests that require network.
+Author: Bas Couwenberg <sebastic at debian.org>
+
+--- a/mapproxy/test/system/test_util_wms_capabilities.py
++++ b/mapproxy/test/system/test_util_wms_capabilities.py
+@@ -17,6 +17,7 @@ from __future__ import with_statement
+ import os
+ 
+ from nose.tools import assert_raises
++from nose.plugins.skip import SkipTest
+ 
+ from mapproxy.client.http import HTTPClient
+ from mapproxy.script.wms_capabilities import wms_capabilities_command
+@@ -36,6 +37,9 @@ class TestUtilWMSCapabilities(object):
+         self.args = ['command_dummy', '--host', TESTSERVER_URL + '/service']
+ 
+     def test_http_error(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         self.args = ['command_dummy', '--host', 'http://foo.doesnotexist']
+         with capture() as (out,err):
+             assert_raises(SystemExit, wms_capabilities_command, self.args)
+@@ -47,6 +51,9 @@ class TestUtilWMSCapabilities(object):
+         assert err.getvalue().startswith("ERROR:")
+ 
+     def test_request_not_parsable(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/service?request=GetCapabilities&version=1.1.1&service=WMS', 'method': 'GET'},
+                                               {'status': '200', 'body': ''})]):
+             with capture() as (out,err):
+@@ -55,6 +62,9 @@ class TestUtilWMSCapabilities(object):
+             assert error_msg.startswith('Could not parse the document')
+ 
+     def test_service_exception(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         self.args = ['command_dummy', '--host', TESTSERVER_URL + '/service?request=GetCapabilities']
+         with open(SERVICE_EXCEPTION_FILE, 'rb') as fp:
+             capabilities_doc = fp.read()
+@@ -66,6 +76,9 @@ class TestUtilWMSCapabilities(object):
+                 assert 'Not a capabilities document' in error_msg
+ 
+     def test_parse_capabilities(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         self.args = ['command_dummy', '--host', TESTSERVER_URL + '/service?request=GetCapabilities', '--version', '1.1.1']
+         with open(CAPABILITIES111_FILE, 'rb') as fp:
+             capabilities_doc = fp.read()
+@@ -77,6 +90,9 @@ class TestUtilWMSCapabilities(object):
+                 assert lines[1].startswith('Capabilities Document Version 1.1.1')
+ 
+     def test_parse_130capabilities(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         self.args = ['command_dummy', '--host', TESTSERVER_URL + '/service?request=GetCapabilities', '--version', '1.3.0']
+         with open(CAPABILITIES130_FILE, 'rb') as fp:
+             capabilities_doc = fp.read()
+@@ -88,6 +104,9 @@ class TestUtilWMSCapabilities(object):
+                 assert lines[1].startswith('Capabilities Document Version 1.3.0')
+ 
+     def test_key_error(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         self.args = ['command_dummy', '--host', TESTSERVER_URL + '/service?request=GetCapabilities']
+         with open(CAPABILITIES111_FILE, 'rb') as fp:
+             capabilities_doc = fp.read()
+--- a/mapproxy/test/unit/test_cache.py
++++ b/mapproxy/test/unit/test_cache.py
+@@ -56,6 +56,7 @@ from mapproxy.test.http import assert_qu
+ from collections import defaultdict
+ 
+ from nose.tools import eq_, raises, assert_not_equal, assert_raises
++from nose.plugins.skip import SkipTest
+ 
+ TEST_SERVER_ADDRESS = ('127.0.0.1', 56413)
+ GLOBAL_GEOGRAPHIC_EXTENT = MapExtent((-180, -90, 180, 90), SRS(4326))
+@@ -680,6 +681,9 @@ class TestWMSSourceWithClient(object):
+         self.source = WMSSource(self.client)
+ 
+     def test_get_map(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         with tmp_image((512, 512)) as img:
+             expected_req = ({'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng'
+                                      '&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A4326&styles='
+@@ -693,6 +697,9 @@ class TestWMSSourceWithClient(object):
+                 assert is_png(result.as_buffer(seekable=True))
+                 eq_(result.as_image().size, (512, 512))
+     def test_get_map_non_image_content_type(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         with tmp_image((512, 512)) as img:
+             expected_req = ({'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng'
+                                      '&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A4326&styles='
+@@ -707,6 +714,9 @@ class TestWMSSourceWithClient(object):
+                 else:
+                     assert False, 'no SourceError raised'
+     def test_basic_auth(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         http_client = HTTPClient(self.req_template.url, username='foo', password='bar@')
+         self.client.http_client = http_client
+         def assert_auth(req_handler):
+@@ -873,4 +883,4 @@ class TestNeastedConditionalLayers(objec
+         assert self.l4326.requested
+     def test_resolution_low_projected(self):
+         self.layer.get_map(MapQuery((0, 0, 10000, 10000), (100, 100), SRS(31467)))
+-        assert self.l900913.requested
+\ No newline at end of file
++        assert self.l900913.requested
+--- a/mapproxy/test/unit/test_client.py
++++ b/mapproxy/test/unit/test_client.py
+@@ -43,11 +43,17 @@ class TestHTTPClient(object):
+         self.client = HTTPClient()
+ 
+     def test_post(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/service?foo=bar', 'method': 'POST'},
+                                               {'status': '200', 'body': b''})]):
+             self.client.open(TESTSERVER_URL + '/service', data=b"foo=bar")
+ 
+     def test_internal_error_response(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         try:
+             with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/'},
+                                                   {'status': '500', 'body': b''})]):
+@@ -87,6 +93,9 @@ class TestHTTPClient(object):
+ 
+     @attr('online')
+     def test_https_no_ssl_module_error(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         from mapproxy.client import http
+         old_ssl = http.ssl
+         try:
+@@ -102,6 +111,9 @@ class TestHTTPClient(object):
+ 
+     @attr('online')
+     def test_https_no_ssl_module_insecure(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         from mapproxy.client import http
+         old_ssl = http.ssl
+         try:
+@@ -113,6 +125,9 @@ class TestHTTPClient(object):
+ 
+     @attr('online')
+     def test_https_valid_cert(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         try:
+             import ssl; ssl
+         except ImportError:
+@@ -131,6 +146,9 @@ class TestHTTPClient(object):
+ 
+     @attr('online')
+     def test_https_invalid_cert(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         try:
+             import ssl; ssl
+         except ImportError:
+@@ -144,6 +162,9 @@ class TestHTTPClient(object):
+                 assert_re(e.args[0], r'Could not verify connection to URL')
+ 
+     def test_timeouts(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         test_req = ({'path': '/', 'req_assert_function': lambda x: time.sleep(0.5) or True},
+                     {'body': b'nothing'})
+ 
+@@ -214,6 +235,9 @@ class TestTMSClient(object):
+     def setup(self):
+         self.client = TMSClient(TESTSERVER_URL)
+     def test_get_tile(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/9/5/13.png'},
+                                                 {'body': b'tile', 'headers': {'content-type': 'image/png'}})]):
+             resp = self.client.get_tile((5, 13, 9)).source.read()
+@@ -221,6 +245,9 @@ class TestTMSClient(object):
+ 
+ class TestTileClient(object):
+     def test_tc_path(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         template = TileURLTemplate(TESTSERVER_URL + '/%(tc_path)s.png')
+         client = TileClient(template)
+         with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/09/000/000/005/000/000/013.png'},
+@@ -230,6 +257,9 @@ class TestTileClient(object):
+             eq_(resp, b'tile')
+ 
+     def test_quadkey(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         template = TileURLTemplate(TESTSERVER_URL + '/key=%(quadkey)s&format=%(format)s')
+         client = TileClient(template)
+         with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/key=000002303&format=png'},
+@@ -238,6 +268,9 @@ class TestTileClient(object):
+             resp = client.get_tile((5, 13, 9)).source.read()
+             eq_(resp, b'tile')
+     def test_xyz(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         template = TileURLTemplate(TESTSERVER_URL + '/x=%(x)s&y=%(y)s&z=%(z)s&format=%(format)s')
+         client = TileClient(template)
+         with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/x=5&y=13&z=9&format=png'},
+@@ -247,6 +280,9 @@ class TestTileClient(object):
+             eq_(resp, b'tile')
+ 
+     def test_arcgiscache_path(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         template = TileURLTemplate(TESTSERVER_URL + '/%(arcgiscache_path)s.png')
+         client = TileClient(template)
+         with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/L09/R0000000d/C00000005.png'},
+@@ -256,6 +292,9 @@ class TestTileClient(object):
+             eq_(resp, b'tile')
+ 
+     def test_bbox(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         grid = tile_grid(4326)
+         template = TileURLTemplate(TESTSERVER_URL + '/service?BBOX=%(bbox)s')
+         client = TileClient(template, grid=grid)
+--- a/mapproxy/test/unit/test_tiled_source.py
++++ b/mapproxy/test/unit/test_tiled_source.py
+@@ -15,6 +15,8 @@
+ 
+ from __future__ import with_statement
+ 
++import os
++
+ from mapproxy.client.tile import TMSClient
+ from mapproxy.grid import TileGrid
+ from mapproxy.srs import SRS
+@@ -24,6 +26,7 @@ from mapproxy.layer import MapQuery
+ 
+ from mapproxy.test.http import mock_httpd
+ from nose.tools import eq_
++from nose.plugins.skip import SkipTest
+ 
+ TEST_SERVER_ADDRESS = ('127.0.0.1', 56413)
+ TESTSERVER_URL = 'http://%s:%d' % TEST_SERVER_ADDRESS
+@@ -34,6 +37,9 @@ class TestTileClientOnError(object):
+         self.client = TMSClient(TESTSERVER_URL)
+ 
+     def test_cacheable_response(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         error_handler = HTTPSourceErrorHandler()
+         error_handler.add_handler(500, (255, 0, 0), cacheable=True)
+         self.source = TiledSource(self.grid, self.client, error_handler=error_handler)
+@@ -45,6 +51,9 @@ class TestTileClientOnError(object):
+             eq_(resp.as_image().getcolors(), [((256*256), (255, 0, 0))])
+ 
+     def test_image_response(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         error_handler = HTTPSourceErrorHandler()
+         error_handler.add_handler(500, (255, 0, 0), cacheable=False)
+         self.source = TiledSource(self.grid, self.client, error_handler=error_handler)
+@@ -56,6 +65,9 @@ class TestTileClientOnError(object):
+             eq_(resp.as_image().getcolors(), [((256*256), (255, 0, 0))])
+ 
+     def test_multiple_image_responses(self):
++        if 'OFFLINE_TESTS' in os.environ:
++            raise SkipTest
++
+         error_handler = HTTPSourceErrorHandler()
+         error_handler.add_handler(500, (255, 0, 0), cacheable=False)
+         error_handler.add_handler(204, (255, 0, 127, 200), cacheable=True)
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..99c4ae9
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+offline-tests.patch
diff --git a/debian/rules b/debian/rules
index 5064e09..436ddcf 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,10 +1,12 @@
 #!/usr/bin/make -f
 
 #export DH_VERBOSE=1
+
 export PYBUILD_NAME=mapproxy
 
 %:
 	dh $@ --with python2,python3 --buildsystem=pybuild
 
 override_dh_auto_test:
-	@echo "nocheck set, not running tests"
+	OFFLINE_TESTS=1 dh_auto_test || echo "Ignoring test failures"
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mapproxy.git



More information about the Pkg-grass-devel mailing list