Skip to content

Commit

Permalink
Add some unicode in tests for better handling
Browse files Browse the repository at this point in the history
  • Loading branch information
NotSqrt committed Dec 18, 2016
1 parent f8dd111 commit ab8f9ae
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gitlab-webhooks/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def run(*args, **kwargs):
# 1 push message about new commit
hook_calls.expect_call('push', 'commit_dev_branch')
readme_file.content = CI_SCRIPT + '\n# even more content\n'
readme_file.save(branch_name='dev', commit_message='bump2')
readme_file.save(branch_name='dev', commit_message='bump2 with unicode ⇗ ⟾')

##############
# issue events
Expand Down
6 changes: 3 additions & 3 deletions mattermost_gitlab/event_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def format(self):
if self.data['total_commits_count'] > 1:
description += "s"

suffix = str('')
suffix = ''
if len(self.data['commits']) > 0:
suffix = str('\n')
suffix = '\n'

text = '%s pushed %s into the `%s` branch for project [%s](%s).%s' % (
self.data['user_name'],
Expand All @@ -87,7 +87,7 @@ def format(self):
for val in self.data['commits']:
text += "[%s](%s)" % (val['message'], val['url'])

return str(text)
return text

class IssueEvent(BaseEvent):

Expand Down
2 changes: 1 addition & 1 deletion tests/data/gitlab/merge_request/close_merge_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"name": "Example User"
},
"id": "c5ccce8cd46a277dd0723ad5954f44a562c5c67e",
"message": "bump2",
"message": "bump2 with unicode \u21d7 \u27fe",
"timestamp": "2016-12-16T18:13:26+00:00",
"url": "http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"name": "Example User"
},
"id": "c5ccce8cd46a277dd0723ad5954f44a562c5c67e",
"message": "bump2",
"message": "bump2 with unicode \u21d7 \u27fe",
"timestamp": "2016-12-16T18:13:26+00:00",
"url": "http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/data/gitlab/merge_request/merge_merge_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"name": "Example User"
},
"id": "c5ccce8cd46a277dd0723ad5954f44a562c5c67e",
"message": "bump2",
"message": "bump2 with unicode \u21d7 \u27fe",
"timestamp": "2016-12-16T18:13:26+00:00",
"url": "http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/data/gitlab/merge_request/open_merge_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"name": "Example User"
},
"id": "c5ccce8cd46a277dd0723ad5954f44a562c5c67e",
"message": "bump2",
"message": "bump2 with unicode \u21d7 \u27fe",
"timestamp": "2016-12-16T18:13:26+00:00",
"url": "http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/data/gitlab/merge_request/reopen_merge_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"name": "Example User"
},
"id": "c5ccce8cd46a277dd0723ad5954f44a562c5c67e",
"message": "bump2",
"message": "bump2 with unicode \u21d7 \u27fe",
"timestamp": "2016-12-16T18:13:26+00:00",
"url": "http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"name": "Example User"
},
"id": "c5ccce8cd46a277dd0723ad5954f44a562c5c67e",
"message": "bump2",
"message": "bump2 with unicode \u21d7 \u27fe",
"timestamp": "2016-12-16T18:13:26+00:00",
"url": "http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/data/gitlab/merge_request/update_merge_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"name": "Example User"
},
"id": "c5ccce8cd46a277dd0723ad5954f44a562c5c67e",
"message": "bump2",
"message": "bump2 with unicode \u21d7 \u27fe",
"timestamp": "2016-12-16T18:13:26+00:00",
"url": "http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/data/gitlab/note/merge_request_note.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "Example User"
},
"id": "c5ccce8cd46a277dd0723ad5954f44a562c5c67e",
"message": "bump2",
"message": "bump2 with unicode \u21d7 \u27fe",
"timestamp": "2016-12-16T18:13:26+00:00",
"url": "http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/data/gitlab/push/commit_dev_branch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "Example User"
},
"id": "c5ccce8cd46a277dd0723ad5954f44a562c5c67e",
"message": "bump2",
"message": "bump2 with unicode \u21d7 \u27fe",
"modified": [
"README.md"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/data/gitlab/push/commit_dev_branch.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Example User pushed 1 commit into the `refs/heads/dev` branch for project [example repository](http://gitlab.example.com/root/example-repository).
[bump2](http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e)
[bump2 with unicode ⇗ ⟾](http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e)
2 changes: 1 addition & 1 deletion tests/data/gitlab/push/commit_merge_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "Example User"
},
"id": "c5ccce8cd46a277dd0723ad5954f44a562c5c67e",
"message": "bump2",
"message": "bump2 with unicode \u21d7 \u27fe",
"modified": [
"README.md"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/data/gitlab/push/commit_merge_request.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Example User pushed 2 commits into the `refs/heads/master` branch for project [example repository](http://gitlab.example.com/root/example-repository).
[bump2](http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e)[Merge branch 'dev' into 'master'
[bump2 with unicode ⇗ ⟾](http://gitlab.example.com/root/example-repository/commit/c5ccce8cd46a277dd0723ad5954f44a562c5c67e)[Merge branch 'dev' into 'master'

merge cool feature

Expand Down
3 changes: 2 additions & 1 deletion tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import unittest
import json
import codecs

# Third-party imports

Expand All @@ -20,7 +21,7 @@ def relative_path(name):


def file_content(name):
with open(relative_path(name)) as fp:
with codecs.open(relative_path(name), encoding='utf-8') as fp:
return fp.read()


Expand Down

0 comments on commit ab8f9ae

Please sign in to comment.