Merge lp:~elopio/unity-scope-click/update_new_scopes3 into lp:unity-scope-click/devel

Proposed by Leo Arias
Status: Merged
Approved by: dobey
Approved revision: 265
Merged at revision: 260
Proposed branch: lp:~elopio/unity-scope-click/update_new_scopes3
Merge into: lp:unity-scope-click/devel
Prerequisite: lp:~alecu/unity-scope-click/add-readmes
Diff against target: 299 lines (+79/-47)
6 files modified
HACKING (+6/-0)
autopilot/CMakeLists.txt (+2/-2)
autopilot/unityclickscope/fake_servers.py (+13/-13)
autopilot/unityclickscope/test_click_scope.py (+47/-21)
autopilot/unityclickscope/test_fixture_setup.py (+5/-5)
debian/control (+6/-6)
To merge this branch: bzr merge lp:~elopio/unity-scope-click/update_new_scopes3
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
dobey (community) Approve
Review via email: mp+219783@code.launchpad.net

Commit message

Get the test_install_with_credentials_must_start_download autopilot test running.
Launch the clickscope from the build dir if it's available.
Enter the search query with the unity8 helper.
Updated to use python3.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
dobey (dobey) wrote :

220 + 'updated=2014-05-15+14%3A29%3A38.679354&'
222 + 'created=2014-05-15+14%3A29%3A38.679344&'

These are not necessary to have in this string. Let's drop them to avoid unnecessary content here.

286 Depends: libautopilot-qt (>= 1.4),
299 ubuntu-ui-toolkit-autopilot,
300 unity8-autopilot,

These aren't changed in your diff, but with the conversion to python3 here, I think these dependencies also need to be updated to depend on at least the versions of them which also use python3.

review: Needs Fixing
Revision history for this message
Leo Arias (elopio) wrote :

> 220 + 'updated=2014-05-15+14%3A29%3A38.679354&'
> 222 + 'created=2014-05-15+14%3A29%3A38.679344&'
>
> These are not necessary to have in this string. Let's drop them to avoid
> unnecessary content here.

Done

> 286 Depends: libautopilot-qt (>= 1.4),
> 299 ubuntu-ui-toolkit-autopilot,
> 300 unity8-autopilot,
>
> These aren't changed in your diff, but with the conversion to python3 here, I
> think these dependencies also need to be updated to depend on at least the
> versions of them which also use python3.

<elopio> dobey: dpkg-architecture -c sets the environment variable $DEB_HOST_MULTIARCH for the command passed as argument.
<elopio> ubuntu-ui-toolkit-autopilot and unity8-autopilot work with py2 and py3 for now. As soon as possible, the py2 support will be dropped.
<elopio> but they don't have a py3 specific version.
<dobey> elopio: the versions in trusty too?
<elopio> dobey: yes.
<elopio> I haven't ran all the tests in trusty yet, as I plan to enable them only on utopic for now.

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'HACKING'
2--- HACKING 2014-05-16 17:20:07 +0000
3+++ HACKING 2014-05-16 17:20:07 +0000
4@@ -38,6 +38,12 @@
5 $ make check-valgrind
6
7
8+Running the autopilot tests
9+---------------------------
10+
11+ $ make test-click-scope-autopilot-fake-servers
12+
13+
14 Running the scope
15 -----------------
16
17
18=== modified file 'autopilot/CMakeLists.txt'
19--- autopilot/CMakeLists.txt 2014-02-06 17:15:05 +0000
20+++ autopilot/CMakeLists.txt 2014-05-16 17:20:07 +0000
21@@ -13,7 +13,7 @@
22 DESTINATION ${PYTHON_PACKAGE_DIR}
23 )
24
25-add_custom_target(test-click-scope-autopilot-local
26- COMMAND U1_SEARCH_BASE_URL=fake DOWNLOAD_BASE_URL=fake autopilot run ${AUTOPILOT_DIR}
27+add_custom_target(test-click-scope-autopilot-fake-servers
28+ COMMAND U1_SEARCH_BASE_URL=fake DOWNLOAD_BASE_URL=fake BUILD_DIR=${CMAKE_BINARY_DIR} autopilot3 run -v ${AUTOPILOT_DIR}
29 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
30 )
31
32=== modified file 'autopilot/unityclickscope/fake_servers.py'
33--- autopilot/unityclickscope/fake_servers.py 2014-02-01 12:31:42 +0000
34+++ autopilot/unityclickscope/fake_servers.py 2014-05-16 17:20:07 +0000
35@@ -14,28 +14,28 @@
36 # You should have received a copy of the GNU General Public License
37 # along with this program. If not, see <http://www.gnu.org/licenses/>.
38
39-import BaseHTTPServer
40 import copy
41+import http.server
42 import json
43 import os
44 import tempfile
45-import urlparse
46-
47-
48-class BaseFakeHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
49+import urllib.parse
50+
51+
52+class BaseFakeHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
53
54 def send_json_reply(self, code, reply_json):
55 self.send_response(code)
56 self.send_header('Content-Type', 'application/json')
57 self.end_headers()
58- self.wfile.write(reply_json)
59+ self.wfile.write(reply_json.encode())
60
61 def send_file(self, file_path, send_body=True, extra_headers={}):
62 with open(file_path) as file_:
63 data = file_.read()
64 self.send_response(200)
65 self.send_header('Content-Length', str(len(data)))
66- for key, value in extra_headers.iteritems():
67+ for key, value in extra_headers.items():
68 self.send_header(key, value)
69 self.end_headers()
70 if send_body:
71@@ -45,7 +45,7 @@
72 self.send_file(file_path, send_body=False, extra_headers=extra_headers)
73
74
75-class FakeSearchServer(BaseHTTPServer.HTTPServer, object):
76+class FakeSearchServer(http.server.HTTPServer, object):
77
78 def __init__(self, server_address):
79 super(FakeSearchServer, self).__init__(
80@@ -102,7 +102,7 @@
81 }
82
83 def do_GET(self):
84- parsed_path = urlparse.urlparse(self.path)
85+ parsed_path = urllib.parse.urlparse(self.path)
86 if parsed_path.path.startswith(self._SEARCH_PATH):
87 self.send_json_reply(200, self._get_fake_search_response())
88 elif parsed_path.path.startswith('/extra/'):
89@@ -131,7 +131,7 @@
90 raise NotImplementedError(package)
91
92
93-class FakeDownloadServer(BaseHTTPServer.HTTPServer, object):
94+class FakeDownloadServer(http.server.HTTPServer, object):
95
96 def __init__(self, server_address):
97 super(FakeDownloadServer, self).__init__(
98@@ -141,7 +141,7 @@
99 class FakeDownloadRequestHandler(BaseFakeHTTPRequestHandler):
100
101 def do_HEAD(self):
102- parsed_path = urlparse.urlparse(self.path)
103+ parsed_path = urllib.parse.urlparse(self.path)
104 if parsed_path.path.startswith('/download/'):
105 self._send_dummy_file_headers(parsed_path.path[10:])
106 else:
107@@ -156,7 +156,7 @@
108 def _make_dummy_file(self, name):
109 dummy_file = tempfile.NamedTemporaryFile(
110 prefix='dummy', suffix='.click', delete=False)
111- dummy_file.write('Dummy click file.')
112- dummy_file.write(name)
113+ dummy_file.write('Dummy click file.'.encode())
114+ dummy_file.write(name.encode())
115 dummy_file.close()
116 return dummy_file.name
117
118=== modified file 'autopilot/unityclickscope/test_click_scope.py'
119--- autopilot/unityclickscope/test_click_scope.py 2014-05-13 05:52:34 +0000
120+++ autopilot/unityclickscope/test_click_scope.py 2014-05-16 17:20:07 +0000
121@@ -15,14 +15,15 @@
122 # along with this program. If not, see <http://www.gnu.org/licenses/>.
123
124 import logging
125+import os
126+import shutil
127 import subprocess
128-import os
129
130 import dbusmock
131 import fixtures
132 from autopilot.introspection import dbus as autopilot_dbus
133 from autopilot.matchers import Eventually
134-from testtools.matchers import Equals, MatchesAny
135+from testtools.matchers import Equals
136 from unity8 import process_helpers
137 from unity8.shell import tests as unity_tests
138 from unity8.shell.emulators import dash
139@@ -106,15 +107,40 @@
140 def _restart_scope(self):
141 logging.info('Restarting click scope.')
142 os.system('pkill -f -9 clickscope.ini')
143- lib_path = '/usr/lib/$DEB_HOST_MULTIARCH/'
144- scoperunner_path = os.path.join(lib_path, 'unity-scopes/scoperunner')
145- clickscope_config_ini_path = os.path.join(
146- lib_path, 'unity-scopes/clickscope/clickscope.ini')
147 os.system(
148 "dpkg-architecture -c "
149 "'{scoperunner} \"\" {clickscope}' &".format(
150- scoperunner=scoperunner_path,
151- clickscope=clickscope_config_ini_path))
152+ scoperunner=self._get_scoperunner_path(),
153+ clickscope=self._get_scope_ini_path()))
154+
155+ def _get_scoperunner_path(self):
156+ return os.path.join(
157+ self._get_installed_unity_scopes_lib_dir(), 'scoperunner')
158+
159+ def _get_installed_unity_scopes_lib_dir(self):
160+ return os.path.join('/usr/lib/$DEB_HOST_MULTIARCH/', 'unity-scopes')
161+
162+ def _get_scope_ini_path(self):
163+ build_dir = os.environ.get('BUILD_DIR', None)
164+ if build_dir is not None:
165+ return self._get_built_scope_ini_path(build_dir)
166+ else:
167+ return os.path.join(
168+ self._get_installed_unity_scopes_lib_dir(),
169+ 'clickscope', 'clickscope.ini')
170+
171+ def _get_built_scope_ini_path(self, build_dir):
172+ # The ini and the so files need to be on the same directory.
173+ # We copy them to a temp directory.
174+ temp_dir_fixture = fixtures.TempDir()
175+ self.useFixture(temp_dir_fixture)
176+ shutil.copy(
177+ os.path.join(build_dir, 'data', 'clickscope.ini'),
178+ temp_dir_fixture.path)
179+ shutil.copy(
180+ os.path.join(build_dir, 'scope', 'click', 'libclickscope.so'),
181+ temp_dir_fixture.path)
182+ return os.path.join(temp_dir_fixture.path, 'clickscope.ini')
183
184 def _unlock_screen(self):
185 self.main_window.get_greeter().swipe()
186@@ -125,18 +151,10 @@
187 return scope
188
189 def search(self, query):
190- # TODO move this to the unity8 main view emulator.
191- # --elopio - 2013-12-27
192 search_indicator = self._proxy.select_single(
193 'SearchIndicator', objectName='search')
194 self.touch.tap_object(search_indicator)
195- page_header = self._proxy.select_single(
196- 'PageHeader', objectName='pageHeader')
197- search_container = page_header.select_single(
198- 'QQuickItem', objectName='searchContainer')
199- search_container.state.wait_for(
200- MatchesAny(Equals('narrowActive'), Equals('active')))
201- self.keyboard.type(query)
202+ self.dash.enter_search_query(query)
203
204 def open_app_preview(self, category, name):
205 self.search(name)
206@@ -182,7 +200,6 @@
207 class ClickScopeTestCaseWithCredentials(BaseClickScopeTestCase):
208
209 def setUp(self):
210-# self.skipTest('segfaults. TODO in following branches.')
211 self.add_u1_credentials()
212 super(ClickScopeTestCaseWithCredentials, self).setUp()
213 self.scope = self.open_scope()
214@@ -191,7 +208,12 @@
215 def add_u1_credentials(self):
216 account_manager = credentials.AccountManager()
217 account = account_manager.add_u1_credentials(
218- 'dummy@example.com', 'dummy')
219+ 'dummy@example.com',
220+ 'name=Ubuntu+One+%40+bollo&'
221+ 'consumer_secret=*********&'
222+ 'token=**************&'
223+ 'consumer_key=*******&'
224+ 'token_secret=************')
225 self.addCleanup(account_manager.delete_account, account)
226
227 def test_install_with_credentials_must_start_download(self):
228@@ -211,9 +233,13 @@
229
230 def get_details(self):
231 """Return the details of the application whose preview is open."""
232- card_header = self.select_single('CardHeader', objectName='cardHeader')
233+ header_widget = self.select_single('PreviewWidget', objectName='hdr')
234+ title_label = header_widget.select_single(
235+ 'Label', objectName='titleLabel')
236+ subtitle_label = header_widget.select_single(
237+ 'Label', objectName='subtitleLabel')
238 return dict(
239- title=card_header.title, subtitle=card_header.subtitle)
240+ title=title_label.text, subtitle=subtitle_label.text)
241
242 def install(self):
243 parent = self.get_parent()
244
245=== modified file 'autopilot/unityclickscope/test_fixture_setup.py'
246--- autopilot/unityclickscope/test_fixture_setup.py 2014-01-28 05:21:19 +0000
247+++ autopilot/unityclickscope/test_fixture_setup.py 2014-05-16 17:20:07 +0000
248@@ -14,8 +14,8 @@
249 # You should have received a copy of the GNU General Public License
250 # along with this program. If not, see <http://www.gnu.org/licenses/>.
251
252-import httplib
253-import urlparse
254+import http.client
255+import urllib.parse
256
257 import testscenarios
258 import testtools
259@@ -39,14 +39,14 @@
260 fake_server = self.fixture()
261 self.addCleanup(self._assert_server_not_running)
262 self.useFixture(fake_server)
263- self.netloc = urlparse.urlparse(fake_server.url).netloc
264- connection = httplib.HTTPConnection(self.netloc)
265+ self.netloc = urllib.parse.urlparse(fake_server.url).netloc
266+ connection = http.client.HTTPConnection(self.netloc)
267 self.addCleanup(connection.close)
268 self._do_request(connection)
269 self.assertEqual(connection.getresponse().status, 200)
270
271 def _assert_server_not_running(self):
272- connection = httplib.HTTPConnection(self.netloc)
273+ connection = http.client.HTTPConnection(self.netloc)
274 self.assertRaises(Exception, self._do_request, connection)
275
276 def _do_request(self, connection):
277
278=== modified file 'debian/control'
279--- debian/control 2014-05-05 19:40:20 +0000
280+++ debian/control 2014-05-16 17:20:07 +0000
281@@ -39,12 +39,12 @@
282 Package: unity-scope-click-autopilot
283 Architecture: all
284 Depends: libautopilot-qt (>= 1.4),
285- python-autopilot,
286- python-dbus,
287- python-dbusmock,
288- python-fixtures,
289- python-testscenarios,
290- python-testtools,
291+ python3-autopilot,
292+ python3-dbus,
293+ python3-dbusmock,
294+ python3-fixtures,
295+ python3-testscenarios,
296+ python3-testtools,
297 ubuntu-ui-toolkit-autopilot,
298 unity8-autopilot,
299 ${misc:Depends},

Subscribers

People subscribed via source and target branches

to all changes: