Skip to content

Commit

Permalink
Merge pull request #252 from alphagov/unicode-bugfix
Browse files Browse the repository at this point in the history
Fix UnicodeEncodeError in flash message
  • Loading branch information
TheDoubleK authored Feb 14, 2017
2 parents 43bed56 + 067b61a commit 160621a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/main/views/suppliers.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def put_signed_agreement_on_hold(agreement_id):
agreement = data_api_client.put_signed_agreement_on_hold(agreement_id, current_user.email_address)["agreement"]

organisation = request.form['nameOfOrganisation']
flash('The agreement for {} was put on hold.'.format(organisation), 'message')
flash(u'The agreement for {} was put on hold.'.format(organisation), 'message')

return redirect(url_for(
'.next_agreement',
Expand All @@ -163,7 +163,7 @@ def approve_agreement_for_countersignature(agreement_id):
current_user.id,
)["agreement"]
organisation = request.form['nameOfOrganisation']
flash('The agreement for {} was approved. They will receive a countersigned version soon.'
flash(u'The agreement for {} was approved. They will receive a countersigned version soon.'
.format(organisation), 'message')

return redirect(url_for(
Expand Down
7 changes: 4 additions & 3 deletions tests/app/main/views/test_suppliers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,18 +1281,19 @@ def test_happy_path(self, data_api_client):
assert parsed_location.path == "/admin/suppliers/4321/agreements/g-cloud-99p-world/next"
assert parse_qs(parsed_location.query) == {}

def test_happy_path_with_next_status(self, data_api_client):
def test_happy_path_with_next_status_and_unicode_supplier_name(self, data_api_client):
data_api_client.approve_agreement_for_countersignature.return_value = \
self.put_signed_agreement_on_hold_return_value
res = self.client.post(
"/admin/suppliers/agreements/123/approve?next_status=on-hold",
data={"nameOfOrganisation": "Test"},
data={"nameOfOrganisation": u"Test O\u2019Connor"},
)

data_api_client.approve_agreement_for_countersignature.assert_called_once_with('123',
'[email protected]',
'1234')
assert_flashes(self, "The agreement for Test was approved. They will receive a countersigned version soon.")
assert_flashes(self, u"The agreement for Test O\u2019Connor was approved. They will receive a countersigned "
"version soon.")
assert res.status_code == 302

parsed_location = urlparse(res.location)
Expand Down

0 comments on commit 160621a

Please sign in to comment.