[python-osmapi] 01/07: Imported Upstream version 0.7.0

Bas Couwenberg sebastic at debian.org
Wed Dec 7 18:32:06 UTC 2016


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

sebastic pushed a commit to branch master
in repository python-osmapi.

commit b4661db17384d0360c2203aeb3a4a2df2988992b
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Wed Dec 7 19:19:16 2016 +0100

    Imported Upstream version 0.7.0
---
 .travis.yml                                        |   4 +-
 CHANGELOG.md                                       |   6 +
 README.md                                          |   2 +-
 build.sh                                           |   2 +-
 osmapi/OsmApi.py                                   | 164 +++++++++---------
 osmapi/__init__.py                                 |   2 +-
 requirements.txt                                   |   1 +
 test-requirements.txt                              |   3 +-
 tests/capabilities_test.py                         |   5 +-
 tests/changeset_tests.py                           | 187 ++++++++++++---------
 .../test_ChangesetDownloadContainingUnicode.xml    |  17 ++
 tests/helper_tests.py                              |  68 ++++----
 tests/node_tests.py                                |  88 +++++-----
 tests/notes_tests.py                               |  52 +++---
 tests/osmapi_tests.py                              |  33 ++--
 tests/relation_tests.py                            |  65 ++++---
 tests/way_tests.py                                 |  65 +++----
 17 files changed, 399 insertions(+), 365 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index c421c7f..0975efd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,11 +13,11 @@ before_install:
 
 install:
 - if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then
-     pip install --use-mirrors unittest2;
+     pip install unittest2;
   fi
-- pip install .
 - pip install -r requirements.txt
 - pip install -r test-requirements.txt
+- pip install .
 
 script: ./build.sh
 
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aabbeb2..50a6710 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,12 @@ This project follows [Semantic Versioning](http://semver.org/).
 
 ## [Unreleased][unreleased]
 
+## 0.7.0 - 2016-12-07
+### Changed
+- Replace the old httplib with requests library (thanks a lot [Austin Hartzheim](http://austinhartzheim.me/)!)
+- Use format strings instead of ugly string concatenation
+- Fix unicode in changesets (thanks a lot to [MichaelVL](https://github.com/MichaelVL)!)
+
 ## 0.6.2 - 2016-01-04
 ### Changed
 - Re-arranged README
diff --git a/README.md b/README.md
index 8ae6152..6d1c461 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Python wrapper for the OSM API
 
 ## Installation
 
-Install `osmapi` simply by using pip:
+Install [`osmapi` from PyPi](https://pypi.python.org/pypi/osmapi) by using pip: 
 
     pip install osmapi
 
diff --git a/build.sh b/build.sh
index 64a4f81..d8e53f5 100755
--- a/build.sh
+++ b/build.sh
@@ -9,7 +9,7 @@ function cleanup {
 trap "cleanup" EXIT
 
 # Check PEP-8 code style and McCabe complexity
-flake8 --show-pep8 --show-source .
+flake8 --statistics --show-source .
 
 # run tests
 nosetests --verbose --with-coverage
diff --git a/osmapi/OsmApi.py b/osmapi/OsmApi.py
index 8ca5c57..a58de83 100644
--- a/osmapi/OsmApi.py
+++ b/osmapi/OsmApi.py
@@ -28,15 +28,11 @@ Find all information about changes of the different versions of this module
 """
 
 from __future__ import (absolute_import, print_function, unicode_literals)
-try:
-    import httplib
-except ImportError:
-    import http.client as httplib
-import base64
 import xml.dom.minidom
 import time
 import sys
 import urllib
+import requests
 from datetime import datetime
 
 from osmapi import __version__
@@ -140,7 +136,7 @@ class OsmApi:
             password=None,
             passwordfile=None,
             appid="",
-            created_by="osmapi/"+__version__,
+            created_by="osmapi/%s" % __version__,
             api="https://www.openstreetmap.org",
             changesetauto=False,
             changesetautotags={},
@@ -217,19 +213,19 @@ class OsmApi:
         self._changesetautodata = []
 
         # Get API
-        self._api = api
+        self._api = api.strip('/')
 
         # Get created_by
         if not appid:
             self._created_by = created_by
         else:
-            self._created_by = appid + " (" + created_by + ")"
+            self._created_by = "%s (%s)" % (appid, created_by)
 
         # Initialisation
         self._CurrentChangesetId = 0
 
         # Http connection
-        self._conn = self._get_http_connection()
+        self._session = self._get_http_session()
 
     def __del__(self):
         if self._changesetauto:
@@ -317,9 +313,9 @@ class OsmApi:
         If `NodeVersion` is supplied, this specific version is returned,
         otherwise the latest version is returned.
         """
-        uri = "/api/0.6/node/"+str(NodeId)
+        uri = "/api/0.6/node/%s" % (NodeId)
         if NodeVersion != -1:
-            uri += "/"+str(NodeVersion)
+            uri += "/%s" % (NodeVersion)
         data = self._get(uri)
         if not data:
             return data
@@ -456,7 +452,7 @@ class OsmApi:
 
         `NodeId` is the unique identifier of a node.
         """
-        uri = "/api/0.6/node/"+str(NodeId)+"/history"
+        uri = "/api/0.6/node/%s/history" % NodeId
         data = self._get(uri)
         data = xml.dom.minidom.parseString(data)
         result = {}
@@ -556,7 +552,8 @@ class OsmApi:
         `NodeIdList` is a list containing unique identifiers
         for multiple nodes.
         """
-        uri = "/api/0.6/nodes?nodes=" + ",".join([str(x) for x in NodeIdList])
+        node_list = ",".join([str(x) for x in NodeIdList])
+        uri = "/api/0.6/nodes?nodes=%s" % node_list
         data = self._get(uri)
         data = xml.dom.minidom.parseString(data)
         result = {}
@@ -590,9 +587,9 @@ class OsmApi:
         If `WayVersion` is supplied, this specific version is returned,
         otherwise the latest version is returned.
         """
-        uri = "/api/0.6/way/"+str(WayId)
+        uri = "/api/0.6/way/%s" % (WayId)
         if WayVersion != -1:
-            uri += "/"+str(WayVersion)
+            uri += "/%s" % (WayVersion)
         data = self._get(uri)
         if not data:
             return data
@@ -726,7 +723,7 @@ class OsmApi:
 
         `WayId` is the unique identifier of a way.
         """
-        uri = "/api/0.6/way/"+str(WayId)+"/history"
+        uri = "/api/0.6/way/%s/history" % (WayId)
         data = self._get(uri)
         data = xml.dom.minidom.parseString(data)
         result = {}
@@ -793,7 +790,7 @@ class OsmApi:
 
         The `WayId` is a unique identifier for a way.
         """
-        uri = "/api/0.6/way/"+str(WayId)+"/full"
+        uri = "/api/0.6/way/%s/full" % (WayId)
         data = self._get(uri)
         return self.ParseOsm(data)
 
@@ -811,7 +808,8 @@ class OsmApi:
 
         `WayIdList` is a list containing unique identifiers for multiple ways.
         """
-        uri = "/api/0.6/ways?ways=" + ",".join([str(x) for x in WayIdList])
+        way_list = ",".join([str(x) for x in WayIdList])
+        uri = "/api/0.6/ways?ways=%s" % way_list
         data = self._get(uri)
         data = xml.dom.minidom.parseString(data)
         result = {}
@@ -854,9 +852,9 @@ class OsmApi:
         If `RelationVersion` is supplied, this specific version is returned,
         otherwise the latest version is returned.
         """
-        uri = "/api/0.6/relation/"+str(RelationId)
+        uri = "/api/0.6/relation/%s" % (RelationId)
         if RelationVersion != -1:
-            uri += "/"+str(RelationVersion)
+            uri += "/%s" % (RelationVersion)
         data = self._get(uri)
         if not data:
             return data
@@ -1017,7 +1015,7 @@ class OsmApi:
 
         `RelationId` is the unique identifier of a relation.
         """
-        uri = "/api/0.6/relation/"+str(RelationId)+"/history"
+        uri = "/api/0.6/relation/%s/history" % (RelationId)
         data = self._get(uri)
         data = xml.dom.minidom.parseString(data)
         result = {}
@@ -1125,7 +1123,7 @@ class OsmApi:
 
         If you need all levels, use `OsmApi.RelationFullRecur`.
         """
-        uri = "/api/0.6/relation/"+str(RelationId)+"/full"
+        uri = "/api/0.6/relation/%s/full" % (RelationId)
         data = self._get(uri)
         return self.ParseOsm(data)
 
@@ -1145,7 +1143,7 @@ class OsmApi:
         for multiple relations.
         """
         relation_list = ",".join([str(x) for x in RelationIdList])
-        uri = "/api/0.6/relations?relations=" + relation_list
+        uri = "/api/0.6/relations?relations=%s" % relation_list
         data = self._get(uri)
         data = xml.dom.minidom.parseString(data)
         result = {}
@@ -1185,9 +1183,9 @@ class OsmApi:
         If `include_discussion` is set to `True` the changeset discussion
         will be available in the result.
         """
-        path = "/api/0.6/changeset/"+str(ChangesetId)
+        path = "/api/0.6/changeset/%s" % (ChangesetId)
         if (include_discussion):
-            path = path + "?include_discussion=true"
+            path += "?include_discussion=true"
         data = self._get(path)
         data = xml.dom.minidom.parseString(data)
         data = data.getElementsByTagName("osm")[0]
@@ -1209,7 +1207,7 @@ class OsmApi:
         if "created_by" not in ChangesetTags:
             ChangesetTags["created_by"] = self._created_by
         self._put(
-            "/api/0.6/changeset/" + str(self._CurrentChangesetId),
+            "/api/0.6/changeset/%s" % (self._CurrentChangesetId),
             self._XmlBuild("changeset", {"tag": ChangesetTags})
         )
         return self._CurrentChangesetId
@@ -1254,7 +1252,7 @@ class OsmApi:
         if not self._CurrentChangesetId:
             raise NoChangesetOpenError("No changeset currently opened")
         self._put(
-            "/api/0.6/changeset/"+str(self._CurrentChangesetId)+"/close",
+            "/api/0.6/changeset/%s/close" % (self._CurrentChangesetId),
             ""
         )
         CurrentChangesetId = self._CurrentChangesetId
@@ -1282,17 +1280,17 @@ class OsmApi:
         data += "<osmChange version=\"0.6\" generator=\""
         data += self._created_by + "\">\n"
         for change in ChangesData:
-            data += "<"+change["action"]+">\n"
+            data += "<" + change["action"] + ">\n"
             change["data"]["changeset"] = self._CurrentChangesetId
             data += self._XmlBuild(
                 change["type"],
                 change["data"],
                 False
             ).decode("utf-8")
-            data += "</"+change["action"]+">\n"
+            data += "</" + change["action"] + ">\n"
         data += "</osmChange>"
         data = self._post(
-            "/api/0.6/changeset/"+str(self._CurrentChangesetId)+"/upload",
+            "/api/0.6/changeset/%s/upload" % (self._CurrentChangesetId),
             data.encode("utf-8")
         )
         data = xml.dom.minidom.parseString(data)
@@ -1321,7 +1319,7 @@ class OsmApi:
                 'data': {}
             }
         """
-        uri = "/api/0.6/changeset/"+str(ChangesetId)+"/download"
+        uri = "/api/0.6/changeset/%s/download" % (ChangesetId)
         data = self._get(uri)
         return self.ParseOsc(data)
 
@@ -1371,7 +1369,7 @@ class OsmApi:
         if created_before:
             if not closed_after:
                 closed_after = "1970-01-01T00:00:00Z"
-            params["time"] = closed_after + "," + created_before
+            params["time"] = "%s,%s" % (closed_after, created_before)
         if only_open:
             params["open"] = 1
         if only_closed:
@@ -1420,7 +1418,7 @@ class OsmApi:
         """
         params = urllib.urlencode({'text': comment})
         data = self._post(
-            "/api/0.6/changeset/"+str(ChangesetId)+"/comment",
+            "/api/0.6/changeset/%s/comment" % (ChangesetId),
             params
         )
         data = xml.dom.minidom.parseString(data)
@@ -1457,7 +1455,7 @@ class OsmApi:
         """
         try:
             data = self._post(
-                "/api/0.6/changeset/"+str(ChangesetId)+"/subscribe",
+                "/api/0.6/changeset/%s/subscribe" % (ChangesetId),
                 None
             )
         except ApiError as e:
@@ -1499,7 +1497,7 @@ class OsmApi:
         """
         try:
             data = self._post(
-                "/api/0.6/changeset/"+str(ChangesetId)+"/unsubscribe",
+                "/api/0.6/changeset/%s/unsubscribe" % (ChangesetId),
                 None
             )
         except ApiError as e:
@@ -1828,10 +1826,10 @@ class OsmApi:
         if action == "create":
             if OsmData.get("id", -1) > 0:
                 raise OsmTypeAlreadyExistsError(
-                    "This "+OsmType+" already exists"
+                    "This %s already exists" % OsmType
                 )
             result = self._put(
-                "/api/0.6/" + OsmType + "/create",
+                "/api/0.6/%s/create" % OsmType,
                 self._XmlBuild(OsmType, OsmData)
             )
             OsmData["id"] = int(result.strip())
@@ -1839,14 +1837,14 @@ class OsmApi:
             return OsmData
         elif action == "modify":
             result = self._put(
-                "/api/0.6/" + OsmType + "/" + str(OsmData["id"]),
+                "/api/0.6/%s/%s" % (OsmType, OsmData["id"]),
                 self._XmlBuild(OsmType, OsmData)
             )
             OsmData["version"] = int(result.strip())
             return OsmData
         elif action == "delete":
             result = self._delete(
-                "/api/0.6/" + OsmType + "/" + str(OsmData["id"]),
+                "/api/0.6/%s/%s" % (OsmType, OsmData["id"]),
                 self._XmlBuild(OsmType, OsmData)
             )
             OsmData["version"] = int(result.strip())
@@ -1887,53 +1885,51 @@ class OsmApi:
             self._changesetautocpt = 0
         return None
 
-    def _http_request(self, cmd, path, auth, send):  # noqa
+    def _http_request(self, method, path, auth, send):  # noqa
+        """
+        Returns the response generated by an HTTP request.
+
+        `method` is a HTTP method to be executed
+        with the request data. For example: 'GET' or 'POST'.
+        `path` is the path to the requested resource relative to the
+        base API address stored in self._api. Should start with a
+        slash character to separate the URL.
+        `auth` is a boolean indicating whether authentication should
+        be preformed on this request.
+        `send` contains additional data that might be sent in a
+        request.
+        """
         if self._debug:
             error_msg = (
                 "%s %s %s"
-                % (time.strftime("%Y-%m-%d %H:%M:%S"), cmd, path)
+                % (time.strftime("%Y-%m-%d %H:%M:%S"), method, path)
             )
             print(error_msg, file=sys.stderr)
-        self._conn.putrequest(cmd, path)
-        self._conn.putheader('User-Agent', self._created_by)
+
+        # Add API base URL to path
+        path = self._api + path
+
+        user_pass = None
         if auth:
             try:
-                user_pass = self._username + ':' + self._password
+                user_pass = (self._username, self._password)
             except AttributeError:
                 raise UsernamePasswordMissingError("Username/Password missing")
 
-            try:
-                # Python 2
-                base64_user_pass = base64.encodestring(user_pass).strip()
-            except TypeError:
-                # Python 3
-                base64_user_pass = base64.encodestring(
-                    user_pass.encode('ascii')
-                    ).strip()
-                base64_user_pass = base64_user_pass.decode('utf-8')
-
-            self._conn.putheader(
-                'Authorization',
-                'Basic ' + base64_user_pass
-            )
-        if send is not None:
-            self._conn.putheader('Content-Length', len(send))
-        self._conn.endheaders()
-        if send:
-            self._conn.send(send)
-        response = self._conn.getresponse()
-        if response.status != 200:
-            payload = response.read().strip()
-            if response.status == 410:
+        response = self._session.request(method, path, auth=user_pass,
+                                         data=send)
+        if response.status_code != 200:
+            if response.status_code == 410:
                 return None
-            raise ApiError(response.status, response.reason, payload)
+            payload = response.content.strip()
+            raise ApiError(response.status_code, response.reason, payload)
         if self._debug:
             error_msg = (
                 "%s %s %s"
-                % (time.strftime("%Y-%m-%d %H:%M:%S"), cmd, path)
+                % (time.strftime("%Y-%m-%d %H:%M:%S"), method, path)
             )
             print(error_msg, file=sys.stderr)
-        return response.read()
+        return response.content
 
     def _http(self, cmd, path, auth, send):  # noqa
         i = 0
@@ -1947,7 +1943,7 @@ class OsmApi:
                         raise
                     if i != 1:
                         self._sleep()
-                    self._conn = self._get_http_connection()
+                    self._session = self._get_http_session()
                 else:
                     raise
             except Exception as e:
@@ -1960,17 +1956,17 @@ class OsmApi:
                     )
                 if i != 1:
                     self._sleep()
-                self._conn = self._get_http_connection()
-
-    def _get_http_connection(self):
-        https_str = 'https://'
-        http_str = 'http://'
-        if self._api.lower().startswith(https_str):
-            return httplib.HTTPSConnection(self._api[len(https_str):], 443)
-        elif self._api.lower().startswith(http_str):
-            return httplib.HTTPConnection(self._api[len(http_str):], 80)
-        else:
-            return httplib.HTTPConnection(self._api, 80)
+                self._session = self._get_http_session()
+
+    def _get_http_session(self):
+        """
+        Creates a requests session for connection pooling.
+        """
+        session = requests.Session()
+        session.headers.update({
+            'user-agent': self._created_by
+        })
+        return session
 
     def _sleep(self):
         time.sleep(5)
@@ -2189,7 +2185,7 @@ class OsmApi:
         # <tag... />
         for k, v in ElementData.get("tag", {}).items():
             xml += "    <tag k=\"" + self._XmlEncode(k)
-            xml += "\" v=\"" + self._XmlEncode(v)+"\"/>\n"
+            xml += "\" v=\"" + self._XmlEncode(v) + "\"/>\n"
 
         # <member... />
         for member in ElementData.get("member", []):
@@ -2200,7 +2196,7 @@ class OsmApi:
 
         # <nd... />
         for ref in ElementData.get("nd", []):
-            xml += "    <nd ref=\""+str(ref)+"\"/>\n"
+            xml += "    <nd ref=\"" + str(ref) + "\"/>\n"
 
         # </element>
         xml += "  </" + ElementType + ">\n"
diff --git a/osmapi/__init__.py b/osmapi/__init__.py
index 98014f2..471b807 100644
--- a/osmapi/__init__.py
+++ b/osmapi/__init__.py
@@ -1,5 +1,5 @@
 from __future__ import (absolute_import, print_function, unicode_literals)
 
-__version__ = '0.6.2'
+__version__ = '0.7.0'
 
 from .OsmApi import *  # noqa
diff --git a/requirements.txt b/requirements.txt
index 4565b99..a5a7f8a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,3 +4,4 @@ pypandoc==0.7.0
 Unidecode==0.04.14
 pdoc==0.3.1
 Pygments==1.6
+requests==2.8.0
diff --git a/test-requirements.txt b/test-requirements.txt
index 6cebe16..bb61993 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -1,6 +1,7 @@
 # This file lists the dependencies of this extension.
 # Install with a command like: pip install -r pip-requirements.txt
-flake8==2.1.0
+flake8==3.0.4; python_version >= '2.7'
+flake8==2.1.0; python_version == '2.6'
 nose==1.3.0
 tox==1.7.1
 coverage==3.7.1
diff --git a/tests/capabilities_test.py b/tests/capabilities_test.py
index 79b029e..9961528 100644
--- a/tests/capabilities_test.py
+++ b/tests/capabilities_test.py
@@ -1,14 +1,13 @@
 from __future__ import (unicode_literals, absolute_import)
-from nose.tools import *  # noqa
 from . import osmapi_tests
 
 
 class TestOsmApiNode(osmapi_tests.TestOsmApi):
     def test_Capabilities(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.Capabilities()
-        assert_equals(result, {
+        self.assertEquals(result, {
             'area': {'maximum': 0.25},
             'changesets': {'maximum_elements': 50000.0},
             'status': {
diff --git a/tests/changeset_tests.py b/tests/changeset_tests.py
index c989f91..ba19452 100644
--- a/tests/changeset_tests.py
+++ b/tests/changeset_tests.py
@@ -1,5 +1,4 @@
 from __future__ import (unicode_literals, absolute_import)
-from nose.tools import *  # noqa
 from . import osmapi_tests
 import osmapi
 import mock
@@ -43,21 +42,15 @@ def xmltosorteddict(xml):
     return recursive_sort(xml_dict)
 
 
-def debug(result):
-    from pprint import pprint
-    pprint(result)
-    assert_equals(0, 1)
-
-
 class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
     def test_ChangesetGet(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.ChangesetGet(123)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/changeset/123')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/changeset/123')
 
         self.assertEquals(result, {
             'id': 123,
@@ -78,7 +71,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         })
 
     def test_ChangesetUpdate(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -92,18 +85,17 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             }
         )
 
-        args, _ = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'PUT')
-        self.assertEquals(args[1], '/api/0.6/changeset/4444')
-        sendargs, _ = self.api._conn.send.call_args
+        self.assertEquals(args[1], self.api_base + '/api/0.6/changeset/4444')
         self.assertEquals(
-            xmltosorteddict(sendargs[0]),
+            xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osm version="0.6" generator="osmapi/0.6.2">\n'
+                b'<osm version="0.6" generator="osmapi/0.7.0">\n'
                 b'  <changeset visible="true">\n'
                 b'    <tag k="test" v="foobar"/>\n'
-                b'    <tag k="created_by" v="osmapi/0.6.2"/>\n'
+                b'    <tag k="created_by" v="osmapi/0.7.0"/>\n'
                 b'  </changeset>\n'
                 b'</osm>\n'
             )
@@ -111,7 +103,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         self.assertEquals(result, 4444)
 
     def test_ChangesetUpdate_with_created_by(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -126,15 +118,14 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             }
         )
 
-        args, _ = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'PUT')
-        self.assertEquals(args[1], '/api/0.6/changeset/4444')
-        sendargs, _ = self.api._conn.send.call_args
+        self.assertEquals(args[1], self.api_base + '/api/0.6/changeset/4444')
         self.assertEquals(
-            xmltosorteddict(sendargs[0]),
+            xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osm version="0.6" generator="osmapi/0.6.2">\n'
+                b'<osm version="0.6" generator="osmapi/0.7.0">\n'
                 b'  <changeset visible="true">\n'
                 b'    <tag k="test" v="foobar"/>\n'
                 b'    <tag k="created_by" v="MyTestOSMApp"/>\n'
@@ -145,7 +136,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         self.assertEquals(result, 4444)
 
     def test_ChangesetUpdate_wo_changeset(self):
-        self._conn_mock()
+        self._session_mock()
 
         with self.assertRaisesRegexp(
                 osmapi.NoChangesetOpenError,
@@ -157,7 +148,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             )
 
     def test_ChangesetCreate(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         result = self.api.ChangesetCreate(
             {
@@ -165,18 +156,17 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             }
         )
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'PUT')
-        self.assertEquals(args[1], '/api/0.6/changeset/create')
-        sendargs, kwargs = self.api._conn.send.call_args
+        self.assertEquals(args[1], self.api_base + '/api/0.6/changeset/create')
         self.assertEquals(
-            xmltosorteddict(sendargs[0]),
+            xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osm version="0.6" generator="osmapi/0.6.2">\n'
+                b'<osm version="0.6" generator="osmapi/0.7.0">\n'
                 b'  <changeset visible="true">\n'
                 b'    <tag k="foobar" v="A new test changeset"/>\n'
-                b'    <tag k="created_by" v="osmapi/0.6.2"/>\n'
+                b'    <tag k="created_by" v="osmapi/0.7.0"/>\n'
                 b'  </changeset>\n'
                 b'</osm>\n'
             )
@@ -184,7 +174,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         self.assertEquals(result, 4321)
 
     def test_ChangesetCreate_with_created_by(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         result = self.api.ChangesetCreate(
             {
@@ -193,15 +183,14 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             }
         )
 
-        args, _ = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'PUT')
-        self.assertEquals(args[1], '/api/0.6/changeset/create')
-        sendargs, _ = self.api._conn.send.call_args
+        self.assertEquals(args[1], self.api_base + '/api/0.6/changeset/create')
         self.assertEquals(
-            xmltosorteddict(sendargs[0]),
+            xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osm version="0.6" generator="osmapi/0.6.2">\n'
+                b'<osm version="0.6" generator="osmapi/0.7.0">\n'
                 b'  <changeset visible="true">\n'
                 b'    <tag k="foobar" v="A new test changeset"/>\n'
                 b'    <tag k="created_by" v="CoolTestApp"/>\n'
@@ -212,7 +201,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         self.assertEquals(result, 1234)
 
     def test_ChangesetCreate_with_open_changeset(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         self.api.ChangesetCreate(
             {
@@ -230,7 +219,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             )
 
     def test_ChangesetClose(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -240,12 +229,13 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
 
         self.api.ChangesetClose()
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'PUT')
-        self.assertEquals(args[1], '/api/0.6/changeset/4444/close')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/changeset/4444/close')
 
     def test_ChangesetClose_with_no_changeset(self):
-        self._conn_mock()
+        self._session_mock()
 
         with self.assertRaisesRegexp(
                 osmapi.NoChangesetOpenError,
@@ -253,7 +243,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             self.api.ChangesetClose()
 
     def test_ChangesetUpload_create_node(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -278,15 +268,15 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
 
         result = self.api.ChangesetUpload(changesdata)
 
-        args, _ = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
-        self.assertEquals(args[1], '/api/0.6/changeset/4444/upload')
-        sendargs, _ = self.api._conn.send.call_args
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/changeset/4444/upload')
         self.assertEquals(
-            xmltosorteddict(sendargs[0]),
+            xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osmChange version="0.6" generator="osmapi/0.6.2">\n'
+                b'<osmChange version="0.6" generator="osmapi/0.7.0">\n'
                 b'<create>\n'
                 b'  <node lat="47.123" lon="8.555" visible="true" '
                 b'changeset="4444">\n'
@@ -309,7 +299,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         self.assertEquals(result[0]['data']['version'], 1)
 
     def test_ChangesetUpload_modify_way(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -352,15 +342,15 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
 
         result = self.api.ChangesetUpload(changesdata)
 
-        args, _ = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
-        self.assertEquals(args[1], '/api/0.6/changeset/4444/upload')
-        sendargs, _ = self.api._conn.send.call_args
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/changeset/4444/upload')
         self.assertEquals(
-            xmltosorteddict(sendargs[0]),
+            xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osmChange version="0.6" generator="osmapi/0.6.2">\n'
+                b'<osmChange version="0.6" generator="osmapi/0.7.0">\n'
                 b'<modify>\n'
                 b'  <way id="4294967296" version="2" visible="true" '
                 b'changeset="4444">\n'
@@ -398,7 +388,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         self.assertEquals(data['version'], 3)
 
     def test_ChangesetUpload_delete_relation(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -436,15 +426,15 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
 
         result = self.api.ChangesetUpload(changesdata)
 
-        args, _ = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
-        self.assertEquals(args[1], '/api/0.6/changeset/4444/upload')
-        sendargs, _ = self.api._conn.send.call_args
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/changeset/4444/upload')
         self.assertEquals(
-            xmltosorteddict(sendargs[0]),
+            xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osmChange version="0.6" generator="osmapi/0.6.2">\n'
+                b'<osmChange version="0.6" generator="osmapi/0.7.0">\n'
                 b'<delete>\n'
                 b'  <relation id="676" version="2" visible="true" '
                 b'changeset="4444">\n'
@@ -469,13 +459,14 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         self.assertNotIn('version', data)
 
     def test_ChangesetDownload(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.ChangesetDownload(23123)
 
-        args, _ = self.api._conn.putrequest.call_args
+        args, _ = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/changeset/23123/download')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/changeset/23123/download')
 
         self.assertEquals(len(result), 16)
         self.assertEquals(
@@ -500,15 +491,47 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             }
         )
 
+    def test_ChangesetDownloadContainingUnicode(self):
+        self._session_mock()
+
+        # This changeset contains unicode tag values
+        # Note that the fixture data has been reduced from the
+        # original from openstreetmap.org
+        result = self.api.ChangesetDownload(37393499)
+
+        self.assertEquals(len(result), 2)
+        self.assertEquals(
+            result[1],
+            {
+                'action': 'create',
+                'type': 'way',
+                'data': {
+                    'changeset': 37393499,
+                    'id': 399491497,
+                    'nd': [4022271571, 4022271567, 4022271565],
+                    'tag': {'highway': 'service',
+                            # UTF-8 encoded 'LATIN SMALL LETTER O WITH STROKE'
+                            # Aka. 0xf8 in latin-1/ISO 8859-1
+                            'name': b'S\xc3\xb8nderskovvej'.decode('utf-8'),
+                            'service': 'driveway'},
+                    'timestamp': datetime.datetime(2016, 2, 23, 16, 55, 35),
+                    'uid': 328556,
+                    'user': 'InternationalUser',
+                    'version': 1,
+                    'visible': True
+                }
+            }
+        )
+
     def test_ChangesetsGet(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.ChangesetsGet(
             only_closed=True,
             username='metaodi'
         )
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
         self.assertEquals(
             dict(urlparse.parse_qsl(urlparse.urlparse(args[1])[4])),
@@ -540,15 +563,15 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         })
 
     def test_ChangesetGetWithComment(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.ChangesetGet(52924, include_discussion=True)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
         self.assertEquals(
             args[1],
-            '/api/0.6/changeset/52924?include_discussion=true'
+            self.api_base + '/api/0.6/changeset/52924?include_discussion=true'
         )
 
         self.assertEquals(result, {
@@ -590,19 +613,19 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         })
 
     def test_ChangesetComment(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         result = self.api.ChangesetComment(
             123,
             comment="test comment"
         )
 
-        args, _ = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
-        self.assertEquals(args[1], '/api/0.6/changeset/123/comment')
-        sendargs, _ = self.api._conn.send.call_args
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/changeset/123/comment')
         self.assertEquals(
-            sendargs[0],
+            kwargs['data'],
             "text=test+comment"
         )
         self.assertEquals(result, {
@@ -624,13 +647,14 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         })
 
     def test_ChangesetSubscribe(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         result = self.api.ChangesetSubscribe(123)
 
-        args, _ = self.api._conn.putrequest.call_args
+        args, _ = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
-        self.assertEquals(args[1], '/api/0.6/changeset/123/subscribe')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/changeset/123/subscribe')
         self.assertEquals(result, {
             'id': 123,
             'closed_at': datetime.datetime(2009, 9, 7, 22, 57, 37),
@@ -650,7 +674,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         })
 
     def test_ChangesetSubscribeWhenAlreadySubscribed(self):
-        self._conn_mock(auth=True, status=409)
+        self._session_mock(auth=True, status=409)
 
         with self.assertRaises(osmapi.AlreadySubscribedApiError) as cm:
             self.api.ChangesetSubscribe(52924)
@@ -662,13 +686,14 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         )
 
     def test_ChangesetUnsubscribe(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         result = self.api.ChangesetUnsubscribe(123)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
-        self.assertEquals(args[1], '/api/0.6/changeset/123/unsubscribe')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/changeset/123/unsubscribe')
         self.assertEquals(result, {
             'id': 123,
             'closed_at': datetime.datetime(2009, 9, 7, 22, 57, 37),
@@ -688,7 +713,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
         })
 
     def test_ChangesetUnsubscribeWhenNotSubscribed(self):
-        self._conn_mock(auth=True, status=404)
+        self._session_mock(auth=True, status=404)
 
         with self.assertRaises(osmapi.NotSubscribedApiError) as cm:
             self.api.ChangesetUnsubscribe(52924)
diff --git a/tests/fixtures/test_ChangesetDownloadContainingUnicode.xml b/tests/fixtures/test_ChangesetDownloadContainingUnicode.xml
new file mode 100644
index 0000000..b61d7f1
--- /dev/null
+++ b/tests/fixtures/test_ChangesetDownloadContainingUnicode.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Note, this is not the original data from openstreetmap.org. This changeset has been reduced in size for practical reasons -->
+<osmChange version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
+  <create>
+    <node id="4022271572" changeset="37393499" timestamp="2016-02-23T16:55:35Z" version="1" visible="true" user="InternationalUser" uid="328556" lat="57.0040348" lon="10.1947379"/>
+  </create>
+  <create>
+    <way id="399491497" changeset="37393499" timestamp="2016-02-23T16:55:35Z" version="1" visible="true" user="InternationalUser" uid="328556">
+      <nd ref="4022271571"/>
+      <nd ref="4022271567"/>
+      <nd ref="4022271565"/>
+      <tag k="highway" v="service"/>
+      <tag k="name" v="Sønderskovvej"/>
+      <tag k="service" v="driveway"/>
+    </way>
+  </create>
+</osmChange>
diff --git a/tests/helper_tests.py b/tests/helper_tests.py
index cb9286a..826fcd2 100644
--- a/tests/helper_tests.py
+++ b/tests/helper_tests.py
@@ -1,5 +1,4 @@
 from __future__ import (unicode_literals, absolute_import)
-from nose.tools import *  # noqa
 from . import osmapi_tests
 import osmapi
 import mock
@@ -20,14 +19,10 @@ class TestOsmApiHelper(osmapi_tests.TestOsmApi):
 
     def setupMock(self, status=200):
         mock_response = mock.Mock()
-        mock_response.status = status
+        mock_response.status_code = status
         mock_response.reason = "test reason"
-        mock_response.read = mock.Mock(return_value='test response')
-        self.api._conn.getresponse = mock.Mock(return_value=mock_response)
-        self.api._conn.putrequest = mock.Mock()
-        self.api._conn.putheader = mock.Mock()
-        self.api._conn.send = mock.Mock()
-        self.api._conn.endheaders = mock.Mock()
+        mock_response.content = 'test response'
+        self.api._session.request = mock.Mock(return_value=mock_response)
         self.api._username = 'testuser'
         self.api._password = 'testpassword'
 
@@ -48,45 +43,46 @@ class TestOsmApiHelper(osmapi_tests.TestOsmApi):
             False,
             None
         )
-        self.api._conn.putrequest.assert_called_with('GET', '/api/0.6/test')
+        self.api._session.request.assert_called_with(
+            'GET',
+            self.api_base + '/api/0.6/test',
+            auth=None,
+            data=None
+        )
         self.assertEquals(response, "test response")
-        self.assertEquals(self.api._conn.putheader.call_count, 1)
+        self.assertEquals(self.api._session.request.call_count, 1)
 
     def test_http_request_put(self):
+        data = "data"
         response = self.api._http_request(
             'PUT',
             '/api/0.6/testput',
             False,
-            "data"
+            data
         )
-        self.api._conn.putrequest.assert_called_with(
+        self.api._session.request.assert_called_with(
             'PUT',
-            '/api/0.6/testput'
+            self.api_base + '/api/0.6/testput',
+            data="data",
+            auth=None
         )
         self.assertEquals(response, "test response")
-        self.assertEquals(self.api._conn.putheader.call_count, 2)
-        args = self.api._conn.putheader.call_args_list[1]
-        header, value = args[0]
-        self.assertEquals(header, 'Content-Length')
-        self.assertEquals(value, 4)
 
     def test_http_request_delete(self):
+        data = "delete data"
         response = self.api._http_request(
             'PUT',
             '/api/0.6/testdelete',
             False,
-            "delete data"
+            data
         )
-        self.api._conn.putrequest.assert_called_with(
+        self.api._session.request.assert_called_with(
             'PUT',
-            '/api/0.6/testdelete'
+            self.api_base + '/api/0.6/testdelete',
+            data="delete data",
+            auth=None
         )
         self.assertEquals(response, "test response")
-        self.assertEquals(self.api._conn.putheader.call_count, 2)
-        args = self.api._conn.putheader.call_args_list[1]
-        header, value = args[0]
-        self.assertEquals(header, 'Content-Length')
-        self.assertEquals(value, 11)
 
     def test_http_request_auth(self):
         response = self.api._http_request(
@@ -95,18 +91,14 @@ class TestOsmApiHelper(osmapi_tests.TestOsmApi):
             True,
             None
         )
-        self.api._conn.putrequest.assert_called_with(
+        self.api._session.request.assert_called_with(
             'PUT',
-            '/api/0.6/testauth'
+            self.api_base + '/api/0.6/testauth',
+            auth=('testuser', 'testpassword'),
+            data=None
         )
         self.assertEquals(response, "test response")
 
-        self.assertEquals(self.api._conn.putheader.call_count, 2)
-        args = self.api._conn.putheader.call_args_list[1]
-        header, value = args[0]
-        self.assertEquals(header, 'Authorization')
-        self.assertEquals(value, 'Basic dGVzdHVzZXI6dGVzdHBhc3N3b3Jk')
-
     def test_http_request_410_response(self):
         self.setupMock(410)
         response = self.api._http_request(
@@ -115,9 +107,11 @@ class TestOsmApiHelper(osmapi_tests.TestOsmApi):
             False,
             None
         )
-        self.api._conn.putrequest.assert_called_with(
+        self.api._session.request.assert_called_with(
             'GET',
-            '/api/0.6/test410'
+            self.api_base + '/api/0.6/test410',
+            auth=None,
+            data=None
         )
         self.assertIsNone(response, "test response")
 
@@ -126,7 +120,7 @@ class TestOsmApiHelper(osmapi_tests.TestOsmApi):
         with self.assertRaises(osmapi.ApiError) as cm:
             self.api._http_request(
                 'GET',
-                '/api/0.6/test500',
+                self.api_base + '/api/0.6/test500',
                 False,
                 None
             )
diff --git a/tests/node_tests.py b/tests/node_tests.py
index 8fa1c12..4a82419 100644
--- a/tests/node_tests.py
+++ b/tests/node_tests.py
@@ -1,5 +1,4 @@
 from __future__ import (unicode_literals, absolute_import)
-from nose.tools import *  # noqa
 from . import osmapi_tests
 import osmapi
 import mock
@@ -8,13 +7,13 @@ import datetime
 
 class TestOsmApiNode(osmapi_tests.TestOsmApi):
     def test_NodeGet(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.NodeGet(123)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/node/123')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/node/123')
 
         self.assertEquals(result, {
             'id': 123,
@@ -34,13 +33,13 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
         })
 
     def test_NodeGet_with_version(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.NodeGet(123, NodeVersion=2)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/node/123/2')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/node/123/2')
 
         self.assertEquals(result, {
             'id': 123,
@@ -63,25 +62,24 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
             api="api06.dev.openstreetmap.org",
             changesetauto=True
         )
-        self._conn_mock(auth=True, filenames=[
-            'test_NodeCreate_changesetauto.xml',
-            'test_ChangesetUpload_create_node.xml',
-            'test_ChangesetClose.xml',
-        ])
-
-        test_node = {
-            'lat': 47.123,
-            'lon': 8.555,
-            'tag': {
-                'amenity': 'place_of_worship',
-                'religion': 'pastafarian'
+        for filename in ['test_NodeCreate_changesetauto.xml',
+                         'test_ChangesetUpload_create_node.xml',
+                         'test_ChangesetClose.xml']:
+            self._session_mock(auth=True, filenames=[filename])
+
+            test_node = {
+                'lat': 47.123,
+                'lon': 8.555,
+                'tag': {
+                    'amenity': 'place_of_worship',
+                    'religion': 'pastafarian'
+                }
             }
-        }
 
-        self.assertIsNone(self.api.NodeCreate(test_node))
+            self.assertIsNone(self.api.NodeCreate(test_node))
 
     def test_NodeCreate(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -104,9 +102,9 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
         self.assertEquals(cs, 1111)
         result = self.api.NodeCreate(test_node)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'PUT')
-        self.assertEquals(args[1], '/api/0.6/node/create')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/node/create')
 
         self.assertEquals(result['id'], 9876)
         self.assertEquals(result['lat'], test_node['lat'])
@@ -151,7 +149,7 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
             self.api.NodeCreate(test_node)
 
     def test_NodeCreate_wo_auth(self):
-        self._conn_mock()
+        self._session_mock()
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -173,7 +171,7 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
             self.api.NodeCreate(test_node)
 
     def test_NodeCreate_with_exception(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
         self.api._http_request = mock.Mock(side_effect=Exception)
 
         # setup mock
@@ -196,7 +194,7 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
             self.api.NodeCreate(test_node)
 
     def test_NodeUpdate(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -220,9 +218,9 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
         self.assertEquals(cs, 1111)
         result = self.api.NodeUpdate(test_node)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'PUT')
-        self.assertEquals(args[1], '/api/0.6/node/7676')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/node/7676')
 
         self.assertEquals(result['id'], 7676)
         self.assertEquals(result['version'], 3)
@@ -231,7 +229,7 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
         self.assertEquals(result['tag'], test_node['tag'])
 
     def test_NodeDelete(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -250,20 +248,20 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
 
         result = self.api.NodeDelete(test_node)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'DELETE')
-        self.assertEquals(args[1], '/api/0.6/node/7676')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/node/7676')
         self.assertEquals(result['id'], 7676)
         self.assertEquals(result['version'], 4)
 
     def test_NodeHistory(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.NodeHistory(123)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/node/123/history')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/node/123/history')
 
         self.assertEquals(len(result), 8)
         self.assertEquals(result[4]['id'], 123)
@@ -278,13 +276,13 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
         )
 
     def test_NodeWays(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.NodeWays(234)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/node/234/ways')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/node/234/ways')
 
         self.assertEquals(len(result), 1)
         self.assertEquals(result[0]['id'], 60)
@@ -298,13 +296,14 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
         )
 
     def test_NodeRelations(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.NodeRelations(4295668179)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/node/4295668179/relations')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/node/4295668179/relations')
 
         self.assertEquals(len(result), 1)
         self.assertEquals(result[0]['id'], 4294968148)
@@ -325,13 +324,14 @@ class TestOsmApiNode(osmapi_tests.TestOsmApi):
         )
 
     def test_NodesGet(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.NodesGet([123, 345])
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/nodes?nodes=123,345')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/nodes?nodes=123,345')
 
         self.assertEquals(len(result), 2)
         self.assertEquals(result[123], {
diff --git a/tests/notes_tests.py b/tests/notes_tests.py
index d6121e3..11e0d01 100644
--- a/tests/notes_tests.py
+++ b/tests/notes_tests.py
@@ -1,5 +1,4 @@
 from __future__ import (unicode_literals, absolute_import)
-from nose.tools import *  # noqa
 from . import osmapi_tests
 from datetime import datetime
 
@@ -11,7 +10,7 @@ except ImportError:
 
 class TestOsmApiNotes(osmapi_tests.TestOsmApi):
     def test_NotesGet(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.NotesGet(
             -1.4998534,
@@ -20,9 +19,8 @@ class TestOsmApiNotes(osmapi_tests.TestOsmApi):
             52.4710193
         )
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-
         urlParts = urlparse.urlparse(args[1])
         params = urlparse.parse_qs(urlParts.query)
         self.assertEquals(
@@ -65,13 +63,13 @@ class TestOsmApiNotes(osmapi_tests.TestOsmApi):
         })
 
     def test_NoteGet(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.NoteGet(1111)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/notes/1111')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/notes/1111')
 
         self.assertEquals(result, {
             'id': '1111',
@@ -101,7 +99,7 @@ class TestOsmApiNotes(osmapi_tests.TestOsmApi):
         })
 
     def test_NoteCreate(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         note = {
             'lat': 47.123,
@@ -110,9 +108,8 @@ class TestOsmApiNotes(osmapi_tests.TestOsmApi):
         }
         result = self.api.NoteCreate(note)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
-
         urlParts = urlparse.urlparse(args[1])
         params = urlparse.parse_qs(urlParts.query)
         self.assertEquals(params['lat'][0], '47.123')
@@ -139,7 +136,7 @@ class TestOsmApiNotes(osmapi_tests.TestOsmApi):
         })
 
     def test_NoteCreateAnonymous(self):
-        self._conn_mock()
+        self._session_mock()
 
         note = {
             'lat': 47.123,
@@ -148,9 +145,8 @@ class TestOsmApiNotes(osmapi_tests.TestOsmApi):
         }
         result = self.api.NoteCreate(note)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
-
         urlParts = urlparse.urlparse(args[1])
         params = urlparse.parse_qs(urlParts.query)
         self.assertEquals(params['lat'][0], '47.123')
@@ -177,15 +173,15 @@ class TestOsmApiNotes(osmapi_tests.TestOsmApi):
         })
 
     def test_NoteComment(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         result = self.api.NoteComment(812, 'This is a comment')
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
         self.assertEquals(
             args[1],
-            '/api/0.6/notes/812/comment?text=This+is+a+comment'
+            self.api_base + '/api/0.6/notes/812/comment?text=This+is+a+comment'
         )
 
         self.assertEquals(result, {
@@ -216,15 +212,15 @@ class TestOsmApiNotes(osmapi_tests.TestOsmApi):
         })
 
     def test_NoteCommentAnonymous(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.NoteComment(842, 'blubb')
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
         self.assertEquals(
             args[1],
-            '/api/0.6/notes/842/comment?text=blubb'
+            self.api_base + '/api/0.6/notes/842/comment?text=blubb'
         )
 
         self.assertEquals(result, {
@@ -255,15 +251,15 @@ class TestOsmApiNotes(osmapi_tests.TestOsmApi):
         })
 
     def test_NoteClose(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         result = self.api.NoteClose(814, 'Close this note!')
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
         self.assertEquals(
             args[1],
-            '/api/0.6/notes/814/close?text=Close+this+note%21'
+            self.api_base + '/api/0.6/notes/814/close?text=Close+this+note%21'
         )
 
         self.assertEquals(result, {
@@ -294,15 +290,16 @@ class TestOsmApiNotes(osmapi_tests.TestOsmApi):
         })
 
     def test_NoteReopen(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         result = self.api.NoteReopen(815, 'Reopen this note!')
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'POST')
         self.assertEquals(
             args[1],
-            '/api/0.6/notes/815/reopen?text=Reopen+this+note%21'
+            (self.api_base +
+             '/api/0.6/notes/815/reopen?text=Reopen+this+note%21')
         )
 
         self.assertEquals(result, {
@@ -341,13 +338,12 @@ class TestOsmApiNotes(osmapi_tests.TestOsmApi):
         })
 
     def test_NotesSearch(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.NotesSearch('street')
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-
         urlParts = urlparse.urlparse(args[1])
         params = urlparse.parse_qs(urlParts.query)
         self.assertEquals(params['q'][0], 'street')
diff --git a/tests/osmapi_tests.py b/tests/osmapi_tests.py
index e6e5e4a..c58044b 100644
--- a/tests/osmapi_tests.py
+++ b/tests/osmapi_tests.py
@@ -1,5 +1,4 @@
 from __future__ import unicode_literals
-from nose.tools import *  # noqa
 from osmapi import OsmApi
 import mock
 import os
@@ -20,34 +19,34 @@ __location__ = os.path.realpath(
 
 class TestOsmApi(unittest.TestCase):
     def setUp(self):
+        self.api_base = "http://api06.dev.openstreetmap.org"
         self.api = OsmApi(
-            api="api06.dev.openstreetmap.org"
+            api=self.api_base
         )
         self.maxDiff = None
         print(self._testMethodName)
         print(self.api)
 
-    def _conn_mock(self, auth=False, filenames=None, status=200, reason=None):
+    def _session_mock(self, auth=False, filenames=None, status=200,
+                      reason=None):
         if auth:
             self.api._username = 'testuser'
             self.api._password = 'testpassword'
 
         response_mock = mock.Mock()
-        response_mock.status = status
-        response_mock.reason = reason
-        response_mock.read = mock.Mock(
-            side_effect=self._return_values(filenames)
-        )
+        response_mock.status_code = status
+        return_values = self._return_values(filenames)
+        print(filenames)
+        print(return_values)
+        assert len(return_values) < 2
+        if return_values:
+            response_mock.content = return_values[0]
 
-        conn_mock = mock.Mock()
-        conn_mock.putrequest = mock.Mock()
-        conn_mock.putheader = mock.Mock()
-        conn_mock.endheaders = mock.Mock()
-        conn_mock.send = mock.Mock()
-        conn_mock.getresponse = mock.Mock(return_value=response_mock)
+        session_mock = mock.Mock()
+        session_mock.request = mock.Mock(return_value=response_mock)
 
-        self.api._get_http_connection = mock.Mock(return_value=conn_mock)
-        self.api._conn = conn_mock
+        self.api._get_http_session = mock.Mock(return_value=session_mock)
+        self.api._session = session_mock
 
         self.api._sleep = mock.Mock()
 
@@ -73,4 +72,4 @@ class TestOsmApi(unittest.TestCase):
         pass
 
     def test_constructor(self):
-        assert_true(isinstance(self.api, OsmApi))
+        self.assertTrue(isinstance(self.api, OsmApi))
diff --git a/tests/relation_tests.py b/tests/relation_tests.py
index 7d5c839..5e9fac6 100644
--- a/tests/relation_tests.py
+++ b/tests/relation_tests.py
@@ -1,26 +1,19 @@
 from __future__ import (unicode_literals, absolute_import)
-from nose.tools import *  # noqa
 from . import osmapi_tests
 import osmapi
 import mock
 import datetime
 
 
-def debug(result):
-    from pprint import pprint
-    pprint(result)
-    assert_equals(0, 1)
-
-
 class TestOsmApiRelation(osmapi_tests.TestOsmApi):
     def test_RelationGet(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.RelationGet(321)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/relation/321')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/relation/321')
 
         self.assertEquals(result, {
             'id': 321,
@@ -85,13 +78,13 @@ class TestOsmApiRelation(osmapi_tests.TestOsmApi):
         })
 
     def test_RelationGet_with_version(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.RelationGet(765, 2)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/relation/765/2')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/relation/765/2')
 
         self.assertEquals(result['id'], 765)
         self.assertEquals(result['changeset'], 41378)
@@ -99,7 +92,7 @@ class TestOsmApiRelation(osmapi_tests.TestOsmApi):
         self.assertEquals(result['tag']['source'], 'test')
 
     def test_RelationCreate(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -132,9 +125,9 @@ class TestOsmApiRelation(osmapi_tests.TestOsmApi):
 
         result = self.api.RelationCreate(test_relation)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'PUT')
-        self.assertEquals(args[1], '/api/0.6/relation/create')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/relation/create')
 
         self.assertEquals(result['id'], 8989)
         self.assertEquals(result['version'], 1)
@@ -173,7 +166,7 @@ class TestOsmApiRelation(osmapi_tests.TestOsmApi):
             self.api.RelationCreate(test_relation)
 
     def test_RelationUpdate(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -202,9 +195,9 @@ class TestOsmApiRelation(osmapi_tests.TestOsmApi):
 
         result = self.api.RelationUpdate(test_relation)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'PUT')
-        self.assertEquals(args[1], '/api/0.6/relation/8989')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/relation/8989')
 
         self.assertEquals(result['id'], 8989)
         self.assertEquals(result['version'], 42)
@@ -212,7 +205,7 @@ class TestOsmApiRelation(osmapi_tests.TestOsmApi):
         self.assertEquals(result['tag'], test_relation['tag'])
 
     def test_RelationDelete(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -231,21 +224,22 @@ class TestOsmApiRelation(osmapi_tests.TestOsmApi):
 
         result = self.api.RelationDelete(test_relation)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'DELETE')
-        self.assertEquals(args[1], '/api/0.6/relation/8989')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/relation/8989')
 
         self.assertEquals(result['id'], 8989)
         self.assertEquals(result['version'], 43)
 
     def test_RelationHistory(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.RelationHistory(2470397)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/relation/2470397/history')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/relation/2470397/history')
 
         self.assertEquals(len(result), 2)
         self.assertEquals(result[1]['id'], 2470397)
@@ -259,13 +253,15 @@ class TestOsmApiRelation(osmapi_tests.TestOsmApi):
         self.assertEquals(result[2]['version'], 2)
 
     def test_RelationRelations(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.RelationRelations(1532552)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/relation/1532552/relations')
+        self.assertEquals(args[1],
+                          (self.api_base +
+                           '/api/0.6/relation/1532552/relations'))
 
         self.assertEquals(len(result), 1)
         self.assertEquals(result[0]['id'], 1532553)
@@ -278,13 +274,14 @@ class TestOsmApiRelation(osmapi_tests.TestOsmApi):
         )
 
     def test_RelationFull(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.RelationFull(2470397)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/relation/2470397/full')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/relation/2470397/full')
 
         self.assertEquals(len(result), 11)
         self.assertEquals(result[1]['data']['id'], 101142277)
@@ -295,15 +292,15 @@ class TestOsmApiRelation(osmapi_tests.TestOsmApi):
         self.assertEquals(result[10]['type'], 'relation')
 
     def test_RelationsGet(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.RelationsGet([1532552, 1532553])
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
         self.assertEquals(
             args[1],
-            '/api/0.6/relations?relations=1532552,1532553'
+            self.api_base + '/api/0.6/relations?relations=1532552,1532553'
         )
 
         self.assertEquals(len(result), 2)
diff --git a/tests/way_tests.py b/tests/way_tests.py
index d5f50bc..2a965db 100644
--- a/tests/way_tests.py
+++ b/tests/way_tests.py
@@ -1,5 +1,4 @@
 from __future__ import (unicode_literals, absolute_import)
-from nose.tools import *  # noqa
 from . import osmapi_tests
 import osmapi
 import mock
@@ -8,13 +7,13 @@ import datetime
 
 class TestOsmApiWay(osmapi_tests.TestOsmApi):
     def test_WayGet(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.WayGet(321)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/way/321')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/way/321')
 
         self.assertEquals(result, {
             'id': 321,
@@ -50,31 +49,32 @@ class TestOsmApiWay(osmapi_tests.TestOsmApi):
         })
 
     def test_WayGet_with_version(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.WayGet(4294967296, 2)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/way/4294967296/2')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/way/4294967296/2')
 
         self.assertEquals(result['id'], 4294967296)
         self.assertEquals(result['changeset'], 41303)
         self.assertEquals(result['user'], 'metaodi')
 
     def test_WayGet_nodata(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.WayGet(321)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/way/321')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/way/321')
 
         self.assertEquals(result, '')
 
     def test_WayCreate(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -97,9 +97,9 @@ class TestOsmApiWay(osmapi_tests.TestOsmApi):
 
         result = self.api.WayCreate(test_way)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'PUT')
-        self.assertEquals(args[1], '/api/0.6/way/create')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/way/create')
 
         self.assertEquals(result['id'], 5454)
         self.assertEquals(result['nd'], test_way['nd'])
@@ -127,7 +127,7 @@ class TestOsmApiWay(osmapi_tests.TestOsmApi):
             self.api.WayCreate(test_way)
 
     def test_WayUpdate(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -151,9 +151,9 @@ class TestOsmApiWay(osmapi_tests.TestOsmApi):
 
         result = self.api.WayUpdate(test_way)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'PUT')
-        self.assertEquals(args[1], '/api/0.6/way/876')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/way/876')
 
         self.assertEquals(result['id'], 876)
         self.assertEquals(result['version'], 7)
@@ -161,7 +161,7 @@ class TestOsmApiWay(osmapi_tests.TestOsmApi):
         self.assertEquals(result['tag'], test_way['tag'])
 
     def test_WayDelete(self):
-        self._conn_mock(auth=True)
+        self._session_mock(auth=True)
 
         # setup mock
         self.api.ChangesetCreate = mock.Mock(
@@ -180,20 +180,21 @@ class TestOsmApiWay(osmapi_tests.TestOsmApi):
 
         result = self.api.WayDelete(test_way)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'DELETE')
-        self.assertEquals(args[1], '/api/0.6/way/876')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/way/876')
         self.assertEquals(result['id'], 876)
         self.assertEquals(result['version'], 8)
 
     def test_WayHistory(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.WayHistory(4294967296)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/way/4294967296/history')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/way/4294967296/history')
 
         self.assertEquals(len(result), 2)
         self.assertEquals(result[1]['id'], 4294967296)
@@ -206,13 +207,14 @@ class TestOsmApiWay(osmapi_tests.TestOsmApi):
         )
 
     def test_WayRelations(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.WayRelations(4295032193)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/way/4295032193/relations')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/way/4295032193/relations')
 
         self.assertEquals(len(result), 1)
         self.assertEquals(result[0]['id'], 4294968148)
@@ -233,13 +235,13 @@ class TestOsmApiWay(osmapi_tests.TestOsmApi):
         )
 
     def test_WayFull(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.WayFull(321)
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/way/321/full')
+        self.assertEquals(args[1], self.api_base + '/api/0.6/way/321/full')
 
         self.assertEquals(len(result), 17)
         self.assertEquals(result[0]['data']['id'], 11949)
@@ -250,13 +252,14 @@ class TestOsmApiWay(osmapi_tests.TestOsmApi):
         self.assertEquals(result[16]['type'], 'way')
 
     def test_WaysGet(self):
-        self._conn_mock()
+        self._session_mock()
 
         result = self.api.WaysGet([456, 678])
 
-        args, kwargs = self.api._conn.putrequest.call_args
+        args, kwargs = self.api._session.request.call_args
         self.assertEquals(args[0], 'GET')
-        self.assertEquals(args[1], '/api/0.6/ways?ways=456,678')
+        self.assertEquals(args[1],
+                          self.api_base + '/api/0.6/ways?ways=456,678')
 
         self.assertEquals(len(result), 2)
         self.assertIs(type(result[456]), dict)

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



More information about the Pkg-grass-devel mailing list