Merge lp:~diegosarmentero/ubuntu-sso-client/unicode-args into lp:ubuntu-sso-client

Proposed by Diego Sarmentero on 2012-03-16
Status: Merged
Approved by: Natalia Bidart on 2012-03-19
Approved revision: 921
Merged at revision: 927
Proposed branch: lp:~diegosarmentero/ubuntu-sso-client/unicode-args
Merge into: lp:ubuntu-sso-client
Diff against target: 127 lines (+75/-9)
2 files modified
ubuntu_sso/qt/main.py (+6/-0)
ubuntu_sso/qt/tests/test_main.py (+69/-9)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-sso-client/unicode-args
Reviewer Review Type Date Requested Status
Natalia Bidart 2012-03-16 Approve on 2012-03-19
dobey (community) Approve on 2012-03-16
Roberto Alsina (community) Approve on 2012-03-16
Review via email: mp+97936@code.launchpad.net

Commit message

- Decode the content of help_text (LP: #951371).

To post a comment you must log in.
Roberto Alsina (ralsina) wrote :

+1

review: Approve
dobey (dobey) :
review: Approve
Natalia Bidart (nataliabidart) wrote :

Looks good!

review: Approve
Ubuntu One Auto Pilot (otto-pilot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/qt/main.py'
2--- ubuntu_sso/qt/main.py 2012-03-16 22:33:29 +0000
3+++ ubuntu_sso/qt/main.py 2012-03-19 20:20:23 +0000
4@@ -41,6 +41,12 @@
5 data.append(unicode(qss.data()))
6 app.setStyleSheet('\n'.join(data))
7
8+ # Fix the string that contains unicode chars.
9+ for key in kwargs:
10+ value = kwargs[key]
11+ if isinstance(value, str):
12+ kwargs[key] = value.decode('utf-8')
13+
14 # Unused variable 'ui', pylint: disable=W0612
15 ui = UbuntuSSOClientGUI(close_callback=app.exit, **kwargs)
16 style = QtGui.QStyle.alignedRect(
17
18=== modified file 'ubuntu_sso/qt/tests/test_main.py'
19--- ubuntu_sso/qt/tests/test_main.py 2012-03-16 22:33:29 +0000
20+++ ubuntu_sso/qt/tests/test_main.py 2012-03-19 20:20:23 +0000
21@@ -21,6 +21,7 @@
22 from twisted.trial.unittest import TestCase
23
24 from ubuntu_sso.qt import main
25+from ubuntu_sso import tests
26
27
28 # pylint: disable=C0103
29@@ -36,6 +37,50 @@
30 """Fake setGeometry."""
31
32 show = setGeometry
33+
34+
35+class FakeDesktop(object):
36+
37+ """Fake Desktop Widget."""
38+
39+ def availableGeometry(self):
40+ """Fake availableGeometry for desktop.-"""
41+ return QtCore.QRect(100, 100, 100, 100)
42+
43+
44+class FakeApplication(object):
45+
46+ """Fake QApplication."""
47+
48+ called = {}
49+ __instance = None
50+
51+ def __init__(self, args):
52+ self.called['args'] = args
53+ FakeApplication.__instance = self
54+
55+ def setStyleSheet(self, style):
56+ """Fake setStyleSheet."""
57+ self.called["setStyleSheet"] = style
58+
59+ def styleSheet(self):
60+ """Fake get style sheet."""
61+ return self.called.get("setStyleSheet", '')
62+
63+ def desktop(self):
64+ """Fake Desktop."""
65+ return FakeDesktop()
66+
67+ def exec_(self):
68+ """Fake exec_."""
69+
70+ def exit(self):
71+ """Fake exit."""
72+
73+ @classmethod
74+ def instance(cls):
75+ """Fake instance."""
76+ return FakeApplication.__instance
77 # pylint: enable=C0103
78
79
80@@ -53,17 +98,32 @@
81 return FakeUi()
82
83 self.patch(main, 'UbuntuSSOClientGUI', called_ui)
84- self.patch(main.QtGui.QApplication, 'exec_',
85- lambda *a: self.called.append('main'))
86+ self.patch(main.QtGui, 'QApplication', FakeApplication)
87
88 def test_main(self):
89 """Calling main.main() a UI instance is created."""
90-
91- kwargs = dict(foo='foo', bar='bar', baz='yadda', yadda=0)
92- main.main(**kwargs)
93-
94- kwargs['close_callback'] = main.QtGui.QApplication.instance().exit
95- self.assertEqual(self.called, [('GUI', kwargs), 'main'])
96+ kwargs = dict(app_name='APP_NAME', foo='foo', bar='bar',
97+ baz='yadda', yadda=0)
98+ main.main(**kwargs)
99+
100+ kwargs['close_callback'] = main.QtGui.QApplication.instance().exit
101+ self.assertEqual(self.called, [('GUI', kwargs)])
102+
103+ def test_main_args(self):
104+ """Calling main.main() a UI instance is created."""
105+ arg_list = (tests.APP_NAME, tests.NAME, tests.PASSWORD,
106+ tests.EMAIL_TOKEN)
107+ kwargs = dict(app_name=arg_list[0].encode('utf-8'),
108+ foo=arg_list[1].encode('utf-8'),
109+ bar=arg_list[2].encode('utf-8'),
110+ baz=arg_list[3].encode('utf-8'))
111+ main.main(**kwargs)
112+
113+ kwargs['close_callback'] = main.QtGui.QApplication.instance().exit
114+ expected = dict(app_name=arg_list[0], foo=arg_list[1],
115+ bar=arg_list[2], baz=arg_list[3],
116+ close_callback=main.QtGui.QApplication.instance().exit)
117+ self.assertEqual(self.called, [('GUI', expected)])
118
119 def test_styles_load(self):
120 """Test that all stylesheets load."""
121@@ -74,5 +134,5 @@
122 qss = QtCore.QResource(qss_name)
123 data.append(unicode(qss.data()))
124 self.assertEqual(
125- unicode(QtCore.QCoreApplication.instance().styleSheet()),
126+ unicode(main.QtGui.QApplication.instance().styleSheet()),
127 '\n'.join(data))

Subscribers

People subscribed via source and target branches