[python-osmapi] 01/05: New upstream version 1.0.1
Bas Couwenberg
sebastic at debian.org
Thu Sep 7 08:33:30 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 ba66499fc0d7435cfc76c802a6db8dbfd250fed6
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Thu Sep 7 10:00:04 2017 +0200
New upstream version 1.0.1
---
CHANGELOG.md | 4 ++++
osmapi/OsmApi.py | 44 ++++++++++++++++++++++++++++-------
osmapi/__init__.py | 2 +-
tests/changeset_tests.py | 18 +++++++-------
tests/fixtures/test_WayGet_nodata.xml | 0
tests/functional_tests.py | 1 +
tests/way_tests.py | 11 ---------
7 files changed, 51 insertions(+), 29 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 71fd1c6..008dad5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased][unreleased]
+## 1.0.1 - 2017-09-07
+### Fixed
+- Make sure tests run offline
+
## 1.0.0 - 2017-09-05
### Added
- Officially support Python 3.5 and 3.6
diff --git a/osmapi/OsmApi.py b/osmapi/OsmApi.py
index 087cc83..a43efd3 100644
--- a/osmapi/OsmApi.py
+++ b/osmapi/OsmApi.py
@@ -235,8 +235,12 @@ class OsmApi:
self._session = self._get_http_session()
def __del__(self):
- if self._changesetauto:
- self._changesetautoflush(True)
+ try:
+ if self._changesetauto:
+ self._changesetautoflush(True)
+ except ValueError:
+ pass
+
return None
##################################################
@@ -319,13 +323,14 @@ class OsmApi:
If `NodeVersion` is supplied, this specific version is returned,
otherwise the latest version is returned.
+
+ If the requested element has been deleted,
+ `OsmApi.ElementDeletedApiError` is raised.
"""
uri = "/api/0.6/node/%s" % (NodeId)
if NodeVersion != -1:
uri += "/%s" % (NodeVersion)
data = self._get(uri)
- if not data:
- return data
data = xml.dom.minidom.parseString(data)
data = data.getElementsByTagName("osm")[0]
data = data.getElementsByTagName("node")[0]
@@ -443,6 +448,9 @@ class OsmApi:
If there is already an open changeset,
`OsmApi.ChangesetAlreadyOpenError` is raised.
+
+ If the requested element has already been deleted,
+ `OsmApi.ElementDeletedApiError` is raised.
"""
return self._do("delete", "node", NodeData)
@@ -593,13 +601,14 @@ class OsmApi:
If `WayVersion` is supplied, this specific version is returned,
otherwise the latest version is returned.
+
+ If the requested element has been deleted,
+ `OsmApi.ElementDeletedApiError` is raised.
"""
uri = "/api/0.6/way/%s" % (WayId)
if WayVersion != -1:
uri += "/%s" % (WayVersion)
data = self._get(uri)
- if not data:
- return data
data = xml.dom.minidom.parseString(data)
data = data.getElementsByTagName("osm")[0]
data = data.getElementsByTagName("way")[0]
@@ -714,6 +723,9 @@ class OsmApi:
If there is already an open changeset,
`OsmApi.ChangesetAlreadyOpenError` is raised.
+
+ If the requested element has already been deleted,
+ `OsmApi.ElementDeletedApiError` is raised.
"""
return self._do("delete", "way", WayData)
@@ -796,6 +808,9 @@ class OsmApi:
]
The `WayId` is a unique identifier for a way.
+
+ If the requested element has been deleted,
+ `OsmApi.ElementDeletedApiError` is raised.
"""
uri = "/api/0.6/way/%s/full" % (WayId)
data = self._get(uri)
@@ -858,13 +873,14 @@ class OsmApi:
If `RelationVersion` is supplied, this specific version is returned,
otherwise the latest version is returned.
+
+ If the requested element has been deleted,
+ `OsmApi.ElementDeletedApiError` is raised.
"""
uri = "/api/0.6/relation/%s" % (RelationId)
if RelationVersion != -1:
uri += "/%s" % (RelationVersion)
data = self._get(uri)
- if not data:
- return data
data = xml.dom.minidom.parseString(data)
data = data.getElementsByTagName("osm")[0]
data = data.getElementsByTagName("relation")[0]
@@ -1006,6 +1022,9 @@ class OsmApi:
If there is already an open changeset,
`OsmApi.ChangesetAlreadyOpenError` is raised.
+
+ If the requested element has already been deleted,
+ `OsmApi.ElementDeletedApiError` is raised.
"""
return self._do("delete", "relation", RelationData)
@@ -1095,6 +1114,9 @@ class OsmApi:
If you don't need all levels, use `OsmApi.RelationFull`
instead, which return only 2 levels.
+
+ If any relation (on any level) has been deleted,
+ `OsmApi.ElementDeletedApiError` is raised.
"""
data = []
todo = [RelationId]
@@ -1129,6 +1151,9 @@ class OsmApi:
The `RelationId` is a unique identifier for a way.
If you need all levels, use `OsmApi.RelationFullRecur`.
+
+ If the requested element has been deleted,
+ `OsmApi.ElementDeletedApiError` is raised.
"""
uri = "/api/0.6/relation/%s/full" % (RelationId)
data = self._get(uri)
@@ -1629,6 +1654,9 @@ class OsmApi:
If no authentication information are provided,
`OsmApi.UsernamePasswordMissingError` is raised.
+
+ If the requested element has been deleted,
+ `OsmApi.ElementDeletedApiError` is raised.
"""
path = "/api/0.6/notes/%s/reopen" % NoteId
return self._NoteAction(path, comment, optionalAuth=False)
diff --git a/osmapi/__init__.py b/osmapi/__init__.py
index 1a2cd5f..4711e90 100644
--- a/osmapi/__init__.py
+++ b/osmapi/__init__.py
@@ -1,5 +1,5 @@
from __future__ import (absolute_import, print_function, unicode_literals)
-__version__ = '1.0.0'
+__version__ = '1.0.1'
from .OsmApi import * # noqa
diff --git a/tests/changeset_tests.py b/tests/changeset_tests.py
index a35a10a..82df4d8 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/1.0.0">\n'
+ b'<osm version="0.6" generator="osmapi/1.0.1">\n'
b' <changeset visible="true">\n'
b' <tag k="test" v="foobar"/>\n'
- b' <tag k="created_by" v="osmapi/1.0.0"/>\n'
+ b' <tag k="created_by" v="osmapi/1.0.1"/>\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/1.0.0">\n'
+ b'<osm version="0.6" generator="osmapi/1.0.1">\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/1.0.0">\n'
+ b'<osm version="0.6" generator="osmapi/1.0.1">\n'
b' <changeset visible="true">\n'
b' <tag k="foobar" v="A new test changeset"/>\n'
- b' <tag k="created_by" v="osmapi/1.0.0"/>\n'
+ b' <tag k="created_by" v="osmapi/1.0.1"/>\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/1.0.0">\n'
+ b'<osm version="0.6" generator="osmapi/1.0.1">\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/1.0.0">\n'
+ b'<osmChange version="0.6" generator="osmapi/1.0.1">\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/1.0.0">\n'
+ b'<osmChange version="0.6" generator="osmapi/1.0.1">\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/1.0.0">\n'
+ b'<osmChange version="0.6" generator="osmapi/1.0.1">\n'
b'<delete>\n'
b' <relation id="676" version="2" visible="true" '
b'changeset="4444">\n'
diff --git a/tests/fixtures/test_WayGet_nodata.xml b/tests/fixtures/test_WayGet_nodata.xml
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/functional_tests.py b/tests/functional_tests.py
index 3bb47ff..0133afe 100644
--- a/tests/functional_tests.py
+++ b/tests/functional_tests.py
@@ -6,6 +6,7 @@ import osmapi
class TestOsmApiFunctional(unittest.TestCase):
@httpretty.activate
def test_deleted_element_raises_exception(self):
+ httpretty.HTTPretty.allow_net_connect = False
httpretty.register_uri(
httpretty.GET,
"https://www.openstreetmap.org/api/0.6/relation/2911456/full",
diff --git a/tests/way_tests.py b/tests/way_tests.py
index 2a965db..3ea5bdc 100644
--- a/tests/way_tests.py
+++ b/tests/way_tests.py
@@ -62,17 +62,6 @@ class TestOsmApiWay(osmapi_tests.TestOsmApi):
self.assertEquals(result['changeset'], 41303)
self.assertEquals(result['user'], 'metaodi')
- def test_WayGet_nodata(self):
- self._session_mock()
-
- result = self.api.WayGet(321)
-
- args, kwargs = self.api._session.request.call_args
- self.assertEquals(args[0], 'GET')
- self.assertEquals(args[1], self.api_base + '/api/0.6/way/321')
-
- self.assertEquals(result, '')
-
def test_WayCreate(self):
self._session_mock(auth=True)
--
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