Skip to content

Commit

Permalink
Add tests for XmlResponseInvalidError
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Oderbolz committed Oct 11, 2017
1 parent 9508c1a commit cf02e5f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/fixtures/test_NodeGet_invalid_response.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="OpenStreetMap server">
</osm>
13 changes: 13 additions & 0 deletions tests/fixtures/test_NoteGet_invalid_xml.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="OpenStreetMap server">
<note lon="12.3133135" lat="37.9305489">
<id>1111</id>
<url>http://api.openstreetmap.org/api/0.6/notes/1111</url>
<reopen_url>http://api.openstreetmap.org/api/0.6/notes/1111/reopen</reopen_url>
<date_created>2013-05-01 20:58:21 UTC</date_created>
<status>closed</status>
<date_closed>2013-08-21 16:43:26 UTC</date_closed>
<comments>
<comment>
</note>
</osm>
6 changes: 6 additions & 0 deletions tests/node_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def test_NodeGet_with_version(self):
},
})

def test_NodeGet_invalid_response(self):
self._session_mock()

with self.assertRaises(osmapi.XmlResponseInvalidError):
self.api.NodeGet(987)

def test_NodeCreate_changesetauto(self):
# setup mock
self.api = osmapi.OsmApi(
Expand Down
7 changes: 7 additions & 0 deletions tests/notes_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import (unicode_literals, absolute_import)
from . import osmapi_tests
from datetime import datetime
import osmapi

try:
import urlparse
Expand Down Expand Up @@ -98,6 +99,12 @@ def test_NoteGet(self):
]
})

def test_NoteGet_invalid_xml(self):
self._session_mock()

with self.assertRaises(osmapi.XmlResponseInvalidError):
self.api.NoteGet(1111)

def test_NoteCreate(self):
self._session_mock(auth=True)

Expand Down

0 comments on commit cf02e5f

Please sign in to comment.