diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f1a7c586..d21e9beb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,10 @@ Change Log Log of changes since the 2.0 version +[3.0.4] - 2018-06-29 + +- Fix error in changeset comments when it has special characters + [3.0.3] - 2018-06-18 - Update osmcha lib version to 0.4.8 diff --git a/osmchadjango/changeset/tasks.py b/osmchadjango/changeset/tasks.py index b6b59ec4..3f462697 100644 --- a/osmchadjango/changeset/tasks.py +++ b/osmchadjango/changeset/tasks.py @@ -120,7 +120,7 @@ def post_comment(self, message=None): """Post comment to changeset.""" response = self.client.post( self.url, - data='text={}'.format(message) + data='text={}'.format(message).encode("utf-8") ) if response.status_code == 200: print( diff --git a/osmchadjango/changeset/tests/test_comment_views.py b/osmchadjango/changeset/tests/test_comment_views.py index cb732e30..82d3551a 100644 --- a/osmchadjango/changeset/tests/test_comment_views.py +++ b/osmchadjango/changeset/tests/test_comment_views.py @@ -74,7 +74,7 @@ class MockResponse(): 'https://api.openstreetmap.org/api/0.6/changeset/{}/comment/'.format( self.harmful_changeset.id ), - data='text={}'.format(message), + data='text={}'.format(message).encode('utf-8'), json=None ) @@ -104,7 +104,7 @@ class MockResponse(): 'https://api.openstreetmap.org/api/0.6/changeset/{}/comment/'.format( self.good_changeset.id ), - data='text={}'.format(message), + data='text={}'.format(message).encode('utf-8'), json=None ) @@ -118,7 +118,7 @@ def test_comment_unreviewed_changeset(self, mock_oauth_client): class MockResponse(): status_code = 200 mock_oauth_client.return_value = MockResponse - + self.client.login(username=self.user.username, password='password') comment = {'comment': 'Hello! Do you know this area?'} message = """Hello! Do you know this area? @@ -135,7 +135,7 @@ class MockResponse(): 'https://api.openstreetmap.org/api/0.6/changeset/{}/comment/'.format( self.changeset.id ), - data='text={}'.format(message), + data='text={}'.format(message).encode('utf-8'), json=None ) diff --git a/osmchadjango/changeset/tests/test_tasks.py b/osmchadjango/changeset/tests/test_tasks.py index 9e02870d..cef263d7 100644 --- a/osmchadjango/changeset/tests/test_tasks.py +++ b/osmchadjango/changeset/tests/test_tasks.py @@ -114,6 +114,6 @@ class MockRequest(): mock_oauth_client.assert_called_with( 'POST', 'https://api.openstreetmap.org/api/0.6/changeset/123456/comment/', - data='text=Reviewed in OSMCha and set as GOOD!', + data=b'text=Reviewed in OSMCha and set as GOOD!', json=None )