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
1=== modified file 'autopilot/application/_launcher.py'
2--- autopilot/application/_launcher.py 2014-01-10 02:59:04 +0000
3+++ autopilot/application/_launcher.py 2014-01-14 01:28:48 +0000
4@@ -63,16 +63,16 @@
5
6 _raise_if_not_empty(kwargs)
7
8- def launch(self, package_id, app_name):
9+ def launch(self, package_id, app_name, app_uris):
10 app_id = _get_click_app_id(package_id, app_name)
11
12 _app_env = self.useFixture(UpstartApplicationEnvironment())
13 _app_env.prepare_environment(app_id, app_name)
14
15- return self._launch_click_app(app_id)
16+ return self._launch_click_app(app_id, app_uris)
17
18- def _launch_click_app(self, app_id):
19- pid = _launch_click_app(app_id)
20+ def _launch_click_app(self, app_id, app_uris):
21+ pid = _launch_click_app(app_id, app_uris)
22 self._add_click_launch_cleanup(app_id, pid)
23
24 logger.info(
25@@ -169,11 +169,12 @@
26 return psutil.pid_exists(pid)
27
28
29-def _launch_click_app(app_id):
30+def _launch_click_app(app_id, app_uris):
31 subprocess.check_output([
32 "/sbin/start",
33 "application",
34 "APP_ID={}".format(app_id),
35+ "APP_URIS='{}'".format(app_uris),
36 ])
37
38 return _get_click_app_pid(app_id)
39
40=== modified file 'autopilot/testcase.py'
41--- autopilot/testcase.py 2014-01-09 23:51:18 +0000
42+++ autopilot/testcase.py 2014-01-14 01:28:48 +0000
43@@ -256,7 +256,8 @@
44
45 return self._launch_test_application(launcher, application, *arguments)
46
47- def launch_click_package(self, package_id, app_name=None, **kwargs):
48+ def launch_click_package(self, package_id, app_name=None, app_uris="",
49+ **kwargs):
50 """Launch a click package application with introspection enabled.
51
52 This method takes care of launching a click package with introspection
53@@ -275,6 +276,8 @@
54 :param app_name: Currently, only one application can be packaged in a
55 click package, and this parameter can be left at None. If
56 specified, it should be the application name you wish to launch.
57+ :param app_uris: Parameters used to launch the click package. This
58+ parameter will be left empty if not used.
59
60 :keyword emulator_base: If set, specifies the base class to be used for
61 all emulators for this loaded application.
62@@ -288,7 +291,8 @@
63 launcher = self.useFixture(
64 ClickApplicationLauncher(self.addDetail, **kwargs)
65 )
66- return self._launch_test_application(launcher, package_id, app_name)
67+ return self._launch_test_application(launcher, package_id, app_name,
68+ app_uris)
69
70 # Wrapper function tying the newer ApplicationLauncher behaviour with the
71 # previous (to be depreciated) behaviour
72
73=== modified file 'autopilot/tests/unit/test_application_launcher.py'
74--- autopilot/tests/unit/test_application_launcher.py 2014-01-10 02:59:04 +0000
75+++ autopilot/tests/unit/test_application_launcher.py 2014-01-14 01:28:48 +0000
76@@ -185,7 +185,7 @@
77 launcher.setUp()
78 launcher._launch_click_app = Mock()
79
80- launcher.launch("package_id", "app_name")
81+ launcher.launch("package_id", "app_name", "")
82 prep_env.assert_called_with("app_id", "app_name")
83
84 def test_get_click_app_id_raises_runtimeerror_on_empty_manifest(self):
85@@ -293,7 +293,7 @@
86
87 with patch.object(_l, 'logger'):
88 self.assertThat(
89- launcher._launch_click_app("appid"),
90+ launcher._launch_click_app("appid", ""),
91 Equals(123)
92 )
93
94@@ -408,12 +408,31 @@
95 with patch.object(
96 _l, '_get_click_app_pid'
97 ) as patched_get_click_app_pid:
98- _launch_click_app(test_app_name)
99-
100- check_output.assert_called_with([
101- "/sbin/start",
102- "application",
103- "APP_ID=%s" % test_app_name,
104+ _launch_click_app(test_app_name, "")
105+
106+ check_output.assert_called_with([
107+ "/sbin/start",
108+ "application",
109+ "APP_ID=%s" % test_app_name,
110+ "APP_URIS=''",
111+ ])
112+ patched_get_click_app_pid.assert_called_with(test_app_name)
113+
114+ @patch('autopilot.application._launcher.subprocess.check_output')
115+ def test_launch_click_app_starts_application_with_uri(self, check_output):
116+ test_app_name = self.getUniqueString()
117+ test_app_uris = "%s %s" % (self.getUniqueString(),
118+ self.getUniqueString())
119+ with patch.object(
120+ _l, '_get_click_app_pid'
121+ ) as patched_get_click_app_pid:
122+ _launch_click_app(test_app_name, test_app_uris)
123+
124+ check_output.assert_called_with([
125+ "/sbin/start",
126+ "application",
127+ "APP_ID=%s" % test_app_name,
128+ "APP_URIS='%s'" % test_app_uris,
129 ])
130 patched_get_click_app_pid.assert_called_with(test_app_name)
131

Subscribers

People subscribed via source and target branches