From 7a941fcbda0292928f838560111fc1cb1a4535b7 Mon Sep 17 00:00:00 2001 From: Andy McKay Date: Thu, 11 Oct 2012 11:18:30 -0700 Subject: [PATCH] don't pass unicode names cef can't cope with (bug 791292) --- lib/cef_loggers.py | 4 +++- mkt/receipts/tests/test_views.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/cef_loggers.py b/lib/cef_loggers.py index ab535a3f3e..cbfdfb2af4 100644 --- a/lib/cef_loggers.py +++ b/lib/cef_loggers.py @@ -55,7 +55,9 @@ class CEFLogger: 'suid': str(getattr(user, 'pk', '')), 'signature': '%s%s' % (self.sig_prefix, msg.upper()), 'msg': longer, 'config': c, - 'cs2': app, 'cs2Label': self.cs2label} + # Until the CEF log can cope with unicode app names, just + # use primary keys. + 'cs2': app.pk, 'cs2Label': self.cs2label} if extra_kwargs: kwargs.update(extra_kwargs) diff --git a/mkt/receipts/tests/test_views.py b/mkt/receipts/tests/test_views.py index 9537f2c045..38ff8e0c15 100644 --- a/mkt/receipts/tests/test_views.py +++ b/mkt/receipts/tests/test_views.py @@ -1,3 +1,4 @@ +# -*- coding: utf8 -*- import json from django.conf import settings @@ -313,6 +314,21 @@ class TestReceiptIssue(amo.tests.TestCase): eq_(res.status_code, 200) eq_(create_receipt.call_args[1]['flavour'], 'developer') + @mock.patch('mkt.receipts.views.create_receipt') + def test_unicode_name(self, create_receipt): + """ + Regression test to ensure that the CEF log works. Pass through the + app.pk instead of the full unicode name, until the CEF library is + fixed, or metlog is used. + """ + create_receipt.return_value = 'foo' + self.app.name = u'\u0627\u0644\u062a\u0637\u0628-news' + self.app.save() + + self.client.login(username=self.reviewer.email, password='password') + res = self.client.post(self.url) + eq_(res.status_code, 200) + class TestReceiptCheck(amo.tests.TestCase): fixtures = ['base/users', 'webapps/337141-steamcube']