Merge lp:~sergiusens/autopilot/app_uris into lp:autopilot

Proposed by Sergio Schvezov
Status: Merged
Approved by: Christopher Lee
Approved revision: 412
Merged at revision: 411
Proposed branch: lp:~sergiusens/autopilot/app_uris
Merge into: lp:autopilot
Diff against target: 130 lines (+39/-15)
3 files modified
autopilot/application/_launcher.py (+6/-5)
autopilot/testcase.py (+6/-2)
autopilot/tests/unit/test_application_launcher.py (+27/-8)
To merge this branch: bzr merge lp:~sergiusens/autopilot/app_uris
Reviewer Review Type Date Requested Status
Christopher Lee (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+201525@code.launchpad.net

Commit message

Adding APP_URIS parameter to Click package launching

To post a comment you must log in.
lp:~sergiusens/autopilot/app_uris updated
412. By Sergio Schvezov

s/None/""/

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
Christopher Lee (veebers) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'autopilot/application/_launcher.py'
--- autopilot/application/_launcher.py 2014-01-10 02:59:04 +0000
+++ autopilot/application/_launcher.py 2014-01-14 01:28:48 +0000
@@ -63,16 +63,16 @@
6363
64 _raise_if_not_empty(kwargs)64 _raise_if_not_empty(kwargs)
6565
66 def launch(self, package_id, app_name):66 def launch(self, package_id, app_name, app_uris):
67 app_id = _get_click_app_id(package_id, app_name)67 app_id = _get_click_app_id(package_id, app_name)
6868
69 _app_env = self.useFixture(UpstartApplicationEnvironment())69 _app_env = self.useFixture(UpstartApplicationEnvironment())
70 _app_env.prepare_environment(app_id, app_name)70 _app_env.prepare_environment(app_id, app_name)
7171
72 return self._launch_click_app(app_id)72 return self._launch_click_app(app_id, app_uris)
7373
74 def _launch_click_app(self, app_id):74 def _launch_click_app(self, app_id, app_uris):
75 pid = _launch_click_app(app_id)75 pid = _launch_click_app(app_id, app_uris)
76 self._add_click_launch_cleanup(app_id, pid)76 self._add_click_launch_cleanup(app_id, pid)
7777
78 logger.info(78 logger.info(
@@ -169,11 +169,12 @@
169 return psutil.pid_exists(pid)169 return psutil.pid_exists(pid)
170170
171171
172def _launch_click_app(app_id):172def _launch_click_app(app_id, app_uris):
173 subprocess.check_output([173 subprocess.check_output([
174 "/sbin/start",174 "/sbin/start",
175 "application",175 "application",
176 "APP_ID={}".format(app_id),176 "APP_ID={}".format(app_id),
177 "APP_URIS='{}'".format(app_uris),
177 ])178 ])
178179
179 return _get_click_app_pid(app_id)180 return _get_click_app_pid(app_id)
180181
=== modified file 'autopilot/testcase.py'
--- autopilot/testcase.py 2014-01-09 23:51:18 +0000
+++ autopilot/testcase.py 2014-01-14 01:28:48 +0000
@@ -256,7 +256,8 @@
256256
257 return self._launch_test_application(launcher, application, *arguments)257 return self._launch_test_application(launcher, application, *arguments)
258258
259 def launch_click_package(self, package_id, app_name=None, **kwargs):259 def launch_click_package(self, package_id, app_name=None, app_uris="",
260 **kwargs):
260 """Launch a click package application with introspection enabled.261 """Launch a click package application with introspection enabled.
261262
262 This method takes care of launching a click package with introspection263 This method takes care of launching a click package with introspection
@@ -275,6 +276,8 @@
275 :param app_name: Currently, only one application can be packaged in a276 :param app_name: Currently, only one application can be packaged in a
276 click package, and this parameter can be left at None. If277 click package, and this parameter can be left at None. If
277 specified, it should be the application name you wish to launch.278 specified, it should be the application name you wish to launch.
279 :param app_uris: Parameters used to launch the click package. This
280 parameter will be left empty if not used.
278281
279 :keyword emulator_base: If set, specifies the base class to be used for282 :keyword emulator_base: If set, specifies the base class to be used for
280 all emulators for this loaded application.283 all emulators for this loaded application.
@@ -288,7 +291,8 @@
288 launcher = self.useFixture(291 launcher = self.useFixture(
289 ClickApplicationLauncher(self.addDetail, **kwargs)292 ClickApplicationLauncher(self.addDetail, **kwargs)
290 )293 )
291 return self._launch_test_application(launcher, package_id, app_name)294 return self._launch_test_application(launcher, package_id, app_name,
295 app_uris)
292296
293 # Wrapper function tying the newer ApplicationLauncher behaviour with the297 # Wrapper function tying the newer ApplicationLauncher behaviour with the
294 # previous (to be depreciated) behaviour298 # previous (to be depreciated) behaviour
295299
=== modified file 'autopilot/tests/unit/test_application_launcher.py'
--- autopilot/tests/unit/test_application_launcher.py 2014-01-10 02:59:04 +0000
+++ autopilot/tests/unit/test_application_launcher.py 2014-01-14 01:28:48 +0000
@@ -185,7 +185,7 @@
185 launcher.setUp()185 launcher.setUp()
186 launcher._launch_click_app = Mock()186 launcher._launch_click_app = Mock()
187187
188 launcher.launch("package_id", "app_name")188 launcher.launch("package_id", "app_name", "")
189 prep_env.assert_called_with("app_id", "app_name")189 prep_env.assert_called_with("app_id", "app_name")
190190
191 def test_get_click_app_id_raises_runtimeerror_on_empty_manifest(self):191 def test_get_click_app_id_raises_runtimeerror_on_empty_manifest(self):
@@ -293,7 +293,7 @@
293293
294 with patch.object(_l, 'logger'):294 with patch.object(_l, 'logger'):
295 self.assertThat(295 self.assertThat(
296 launcher._launch_click_app("appid"),296 launcher._launch_click_app("appid", ""),
297 Equals(123)297 Equals(123)
298 )298 )
299299
@@ -408,12 +408,31 @@
408 with patch.object(408 with patch.object(
409 _l, '_get_click_app_pid'409 _l, '_get_click_app_pid'
410 ) as patched_get_click_app_pid:410 ) as patched_get_click_app_pid:
411 _launch_click_app(test_app_name)411 _launch_click_app(test_app_name, "")
412412
413 check_output.assert_called_with([413 check_output.assert_called_with([
414 "/sbin/start",414 "/sbin/start",
415 "application",415 "application",
416 "APP_ID=%s" % test_app_name,416 "APP_ID=%s" % test_app_name,
417 "APP_URIS=''",
418 ])
419 patched_get_click_app_pid.assert_called_with(test_app_name)
420
421 @patch('autopilot.application._launcher.subprocess.check_output')
422 def test_launch_click_app_starts_application_with_uri(self, check_output):
423 test_app_name = self.getUniqueString()
424 test_app_uris = "%s %s" % (self.getUniqueString(),
425 self.getUniqueString())
426 with patch.object(
427 _l, '_get_click_app_pid'
428 ) as patched_get_click_app_pid:
429 _launch_click_app(test_app_name, test_app_uris)
430
431 check_output.assert_called_with([
432 "/sbin/start",
433 "application",
434 "APP_ID=%s" % test_app_name,
435 "APP_URIS='%s'" % test_app_uris,
417 ])436 ])
418 patched_get_click_app_pid.assert_called_with(test_app_name)437 patched_get_click_app_pid.assert_called_with(test_app_name)
419438

Subscribers

People subscribed via source and target branches