[python-osmapi] 01/08: New upstream version 1.0.0

Bas Couwenberg sebastic at debian.org
Tue Sep 5 20:55:19 UTC 2017


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

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

commit 6801a422d5faaadf5245ddc0bf6c1e7fa88d597e
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Tue Sep 5 22:07:23 2017 +0200

    New upstream version 1.0.0
---
 .gitignore                |  1 +
 .travis.yml               |  6 ++----
 CHANGELOG.md              | 10 ++++++++++
 README.md                 | 14 ++++++++++++--
 build.sh                  |  6 ++----
 osmapi/OsmApi.py          | 24 ++++++++++++++++++++++--
 osmapi/__init__.py        |  2 +-
 setup.py                  |  3 ++-
 test-requirements.txt     |  3 ++-
 tests/changeset_tests.py  | 18 +++++++++---------
 tests/functional_tests.py | 17 +++++++++++++++++
 tests/helper_tests.py     | 23 ++++++++++-------------
 tox.ini                   |  6 +-----
 13 files changed, 91 insertions(+), 42 deletions(-)

diff --git a/.gitignore b/.gitignore
index 706a49c..8dacf3c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 dist/
 MANIFEST
 *.pyc
+*.egg-info
 .coverage
 .tox
diff --git a/.travis.yml b/.travis.yml
index 8f21d4d..9491025 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,19 +1,17 @@
 language: python
 
 python:
-- '2.6'
 - '2.7'
 - '3.3'
 - '3.4'
+- '3.5'
+- '3.6'
 
 before_install:
 - sudo apt-get update -qq
 - sudo apt-get install -qq pandoc
 
 install:
-- if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then
-     pip install unittest2;
-  fi
 - pip install -r requirements.txt
 - pip install -r test-requirements.txt
 - pip install .
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e9d9650..71fd1c6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
 
 ## [Unreleased][unreleased]
 
+## 1.0.0 - 2017-09-05
+### Added
+- Officially support Python 3.5 and 3.6
+
+### Removed
+- osmapi does **not** support Python 2.6 anymore (it might work, it might not)
+
+### Changed
+- **BC-Break:** raise an exception if the requested element is deleted (previoulsy `None` has been returned)
+
 ## 0.8.1 - 2016-12-21
 ### Fixed
 - Use setuptools instead of distutils in setup.py
diff --git a/README.md b/README.md
index 6d1c461..4ba0fec 100644
--- a/README.md
+++ b/README.md
@@ -56,7 +56,7 @@ Note: The password file should have the format _user:password_
 
 ```python
 import osmapi
-api = osmapi.OsmApi(username = u"metaodi", password = u"*******")
+api = osmapi.OsmApi(api="api06.dev.openstreetmap.org", username = u"metaodi", password = u"*******")
 api.ChangesetCreate({u"comment": u"My first test"})
 print api.NodeCreate({u"lon":1, u"lat":1, u"tag": {}})
 # {u'changeset': 532907, u'lon': 1, u'version': 1, u'lat': 1, u'tag': {}, u'id': 164684}
@@ -86,10 +86,20 @@ To run the tests use the following command:
 
     nosetests --verbose
 
-By using tox you can even run the tests against different versions of python (2.6, 2.7, 3.2 and 3.3):
+By using tox you can even run the tests against different versions of python (2.7, 3.3, 3.4, 3.5 and 3.6):
 
     tox
 
+## Release
+
+To create a new release, follow these steps (please respect [Semantic Versioning](http://semver.org/)):
+
+1. Adapt the version number in `osmapi/__init__.py`
+1. Update the CHANGELOG with the version
+1. Create a pull request to merge develop into master
+1. Create a [new release/tag on GitHub](https://github.com/metaodi/osmapi/releases) (on the master branch)
+1. The [publication on PyPI](https://pypi.python.org/pypi/osmapi) happens via [Travis CI](https://travis-ci.org/metaodi/osmapi) on every tagged commit
+
 ## Attribution
 
 This project was orginally developed by Etienne Chové.
diff --git a/build.sh b/build.sh
index 4ba4475..d146385 100755
--- a/build.sh
+++ b/build.sh
@@ -14,10 +14,8 @@ flake8 --statistics --show-source .
 # run tests
 nosetests --verbose --with-coverage
 
-# generate docs (currently it's not possible to generate docs in Python 2.6)
-if [[ $TRAVIS_PYTHON_VERSION != 2.6 ]]; then
-    pdoc --html --overwrite osmapi/OsmApi.py
-fi
+# generate the docs
+pdoc --html --overwrite osmapi/OsmApi.py
 
 # setup a new virtualenv and try to install the lib
 virtualenv pyenv
diff --git a/osmapi/OsmApi.py b/osmapi/OsmApi.py
index a58de83..087cc83 100644
--- a/osmapi/OsmApi.py
+++ b/osmapi/OsmApi.py
@@ -122,6 +122,13 @@ class NotSubscribedApiError(ApiError):
     pass
 
 
+class ElementDeletedApiError(ApiError):
+    """
+    Error when the requested element is deleted
+    """
+    pass
+
+
 class OsmApi:
     """
     Main class of osmapi, instanciate this class to use osmapi
@@ -1898,6 +1905,15 @@ class OsmApi:
         be preformed on this request.
         `send` contains additional data that might be sent in a
         request.
+
+        If the username or password is missing,
+        `OsmApi.UsernamePasswordMissingError` is raised.
+
+        If the requested element has been deleted,
+        `OsmApi.ElementDeletedApiError` is raised.
+
+        If the response status code indicates an error,
+        `OsmApi.ApiError` is raised.
         """
         if self._debug:
             error_msg = (
@@ -1919,9 +1935,13 @@ class OsmApi:
         response = self._session.request(method, path, auth=user_pass,
                                          data=send)
         if response.status_code != 200:
-            if response.status_code == 410:
-                return None
             payload = response.content.strip()
+            if response.status_code == 410:
+                raise ElementDeletedApiError(
+                    response.status_code,
+                    response.reason,
+                    payload
+                )
             raise ApiError(response.status_code, response.reason, payload)
         if self._debug:
             error_msg = (
diff --git a/osmapi/__init__.py b/osmapi/__init__.py
index d6adc67..1a2cd5f 100644
--- a/osmapi/__init__.py
+++ b/osmapi/__init__.py
@@ -1,5 +1,5 @@
 from __future__ import (absolute_import, print_function, unicode_literals)
 
-__version__ = '0.8.1'
+__version__ = '1.0.0'
 
 from .OsmApi import *  # noqa
diff --git a/setup.py b/setup.py
index f68d023..24a83ec 100644
--- a/setup.py
+++ b/setup.py
@@ -42,10 +42,11 @@ setup(
         'Topic :: Software Development :: Libraries',
         'Development Status :: 4 - Beta',
         'Programming Language :: Python :: 2',
-        'Programming Language :: Python :: 2.6',
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
         'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
+        'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
     ],
 )
diff --git a/test-requirements.txt b/test-requirements.txt
index 5a410d0..3b52c77 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -3,9 +3,10 @@
 flake8==3.0.4; python_version >= '2.7'
 flake8==2.1.0; python_version == '2.6'
 nose==1.3.0
-tox==1.7.1
+tox==2.8.1
 coverage==3.7.1
 coveralls==0.4.1
 mock==1.0.1
 xmltodict==0.9.0
 virtualenv==15.1.0
+httpretty==0.8.14
diff --git a/tests/changeset_tests.py b/tests/changeset_tests.py
index aeb224e..a35a10a 100644
--- a/tests/changeset_tests.py
+++ b/tests/changeset_tests.py
@@ -92,10 +92,10 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osm version="0.6" generator="osmapi/0.8.1">\n'
+                b'<osm version="0.6" generator="osmapi/1.0.0">\n'
                 b'  <changeset visible="true">\n'
                 b'    <tag k="test" v="foobar"/>\n'
-                b'    <tag k="created_by" v="osmapi/0.8.1"/>\n'
+                b'    <tag k="created_by" v="osmapi/1.0.0"/>\n'
                 b'  </changeset>\n'
                 b'</osm>\n'
             )
@@ -125,7 +125,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osm version="0.6" generator="osmapi/0.8.1">\n'
+                b'<osm version="0.6" generator="osmapi/1.0.0">\n'
                 b'  <changeset visible="true">\n'
                 b'    <tag k="test" v="foobar"/>\n'
                 b'    <tag k="created_by" v="MyTestOSMApp"/>\n'
@@ -163,10 +163,10 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osm version="0.6" generator="osmapi/0.8.1">\n'
+                b'<osm version="0.6" generator="osmapi/1.0.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.8.1"/>\n'
+                b'    <tag k="created_by" v="osmapi/1.0.0"/>\n'
                 b'  </changeset>\n'
                 b'</osm>\n'
             )
@@ -190,7 +190,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osm version="0.6" generator="osmapi/0.8.1">\n'
+                b'<osm version="0.6" generator="osmapi/1.0.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'
@@ -276,7 +276,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osmChange version="0.6" generator="osmapi/0.8.1">\n'
+                b'<osmChange version="0.6" generator="osmapi/1.0.0">\n'
                 b'<create>\n'
                 b'  <node lat="47.123" lon="8.555" visible="true" '
                 b'changeset="4444">\n'
@@ -350,7 +350,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osmChange version="0.6" generator="osmapi/0.8.1">\n'
+                b'<osmChange version="0.6" generator="osmapi/1.0.0">\n'
                 b'<modify>\n'
                 b'  <way id="4294967296" version="2" visible="true" '
                 b'changeset="4444">\n'
@@ -434,7 +434,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
             xmltosorteddict(kwargs['data']),
             xmltosorteddict(
                 b'<?xml version="1.0" encoding="UTF-8"?>\n'
-                b'<osmChange version="0.6" generator="osmapi/0.8.1">\n'
+                b'<osmChange version="0.6" generator="osmapi/1.0.0">\n'
                 b'<delete>\n'
                 b'  <relation id="676" version="2" visible="true" '
                 b'changeset="4444">\n'
diff --git a/tests/functional_tests.py b/tests/functional_tests.py
new file mode 100644
index 0000000..3bb47ff
--- /dev/null
+++ b/tests/functional_tests.py
@@ -0,0 +1,17 @@
+import httpretty
+import unittest
+import osmapi
+
+
+class TestOsmApiFunctional(unittest.TestCase):
+    @httpretty.activate
+    def test_deleted_element_raises_exception(self):
+        httpretty.register_uri(
+            httpretty.GET,
+            "https://www.openstreetmap.org/api/0.6/relation/2911456/full",
+            status=410
+        )
+        with self.assertRaises(osmapi.ElementDeletedApiError) as context:
+            api = osmapi.OsmApi()
+            api.RelationFull(2911456)
+        self.assertEquals(410, context.exception.status)
diff --git a/tests/helper_tests.py b/tests/helper_tests.py
index 826fcd2..76fb596 100644
--- a/tests/helper_tests.py
+++ b/tests/helper_tests.py
@@ -101,19 +101,16 @@ class TestOsmApiHelper(osmapi_tests.TestOsmApi):
 
     def test_http_request_410_response(self):
         self.setupMock(410)
-        response = self.api._http_request(
-            'GET',
-            '/api/0.6/test410',
-            False,
-            None
-        )
-        self.api._session.request.assert_called_with(
-            'GET',
-            self.api_base + '/api/0.6/test410',
-            auth=None,
-            data=None
-        )
-        self.assertIsNone(response, "test response")
+        with self.assertRaises(osmapi.ElementDeletedApiError) as cm:
+            self.api._http_request(
+                'GET',
+                '/api/0.6/test410',
+                False,
+                None
+            )
+        self.assertEquals(cm.exception.status, 410)
+        self.assertEquals(cm.exception.reason, "test reason")
+        self.assertEquals(cm.exception.payload, "test response")
 
     def test_http_request_500_response(self):
         self.setupMock(500)
diff --git a/tox.ini b/tox.ini
index ccb6940..52c4dc7 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,11 +1,7 @@
 [tox]
-envlist = py26,py27,py32,py33,py34
+envlist = py27,py33,py34,py35,py36
 [testenv]
 commands=nosetests --verbose
 deps =
     -r{toxinidir}/requirements.txt
     -r{toxinidir}/test-requirements.txt
-[testenv:py26]
-deps =
-    unittest2
-    {[testenv]deps}

-- 
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