Skip to content

Commit

Permalink
Merge pull request #151 from willemarcel/fix-changeset-comments
Browse files Browse the repository at this point in the history
Fix error in changeset comments when it has special chars
  • Loading branch information
willemarcel authored Jun 30, 2018
2 parents 545db85 + 9f62ea4 commit 5daafa0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion osmchadjango/changeset/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions osmchadjango/changeset/tests/test_comment_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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
)

Expand All @@ -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?
Expand All @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion osmchadjango/changeset/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit 5daafa0

Please sign in to comment.