Merge lp:~mikemc/ubuntu-sso-client/fix-992593-backend-path-darwin-pkgd into lp:ubuntu-sso-client

Proposed by Mike McCracken on 2012-06-29
Status: Rejected
Rejected by: dobey on 2012-07-06
Proposed branch: lp:~mikemc/ubuntu-sso-client/fix-992593-backend-path-darwin-pkgd
Merge into: lp:ubuntu-sso-client
Prerequisite: lp:~mikemc/ubuntu-sso-client/fix-1018924-use-buildout-python
Diff against target: 179 lines (+93/-3)
4 files modified
ubuntu_sso/main/darwin.py (+22/-2)
ubuntu_sso/main/tests/test_darwin.py (+39/-0)
ubuntu_sso/main/tests/test_windows.py (+26/-1)
ubuntu_sso/main/windows.py (+6/-0)
To merge this branch: bzr merge lp:~mikemc/ubuntu-sso-client/fix-992593-backend-path-darwin-pkgd
Reviewer Review Type Date Requested Status
dobey (community) Needs Fixing on 2012-07-06
Diego Sarmentero (community) 2012-06-29 Approve on 2012-07-02
Review via email: mp+112709@code.launchpad.net

Description of the Change

- Use correct path to packaged backend executables on darwin. (LP: #992593)

To post a comment you must log in.
Diego Sarmentero (diegosarmentero) wrote :

I think we can have some tests here to check the different returns.
You can check a test for when we have sys.frozen = True here:
http://bazaar.launchpad.net/~ubuntuone-control-tower/ubuntu-sso-client/trunk/view/head:/ubuntu_sso/utils/tests/test_common.py#L170

review: Needs Fixing
983. By Mike McCracken on 2012-06-29

Merged path-fixes into fix-992593-activation-cmdline.

984. By Mike McCracken on 2012-06-29

Add tests for get_activation_cmdline on darwin and windows.

985. By Mike McCracken on 2012-06-29

add missing import

986. By Mike McCracken on 2012-06-29

add missing import, again

987. By Mike McCracken on 2012-06-29

Fix windows tests and relative path for syncdaemon from source on windows.

Mike McCracken (mikemc) wrote :

Tests added, and made change to use source tree binaries on windows when running from source.

Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
dobey (dobey) wrote :

Why are there references to syncdaemon here? I thought we agreed those belong in ubuntuone-client?

review: Needs Fixing

Unmerged revisions

987. By Mike McCracken on 2012-06-29

Fix windows tests and relative path for syncdaemon from source on windows.

986. By Mike McCracken on 2012-06-29

add missing import, again

985. By Mike McCracken on 2012-06-29

add missing import

984. By Mike McCracken on 2012-06-29

Add tests for get_activation_cmdline on darwin and windows.

983. By Mike McCracken on 2012-06-29

Merged path-fixes into fix-992593-activation-cmdline.

982. By Mike McCracken on 2012-06-29

Use correct paths to backend helper apps on darwin when packaged. (LP: #992593)

981. By Mike McCracken on 2012-06-29

Use buildout python to run subprocesses during development. (LP: #1018924)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/main/darwin.py'
2--- ubuntu_sso/main/darwin.py 2012-06-29 22:29:26 +0000
3+++ ubuntu_sso/main/darwin.py 2012-06-29 22:29:26 +0000
4@@ -27,6 +27,7 @@
5
6 import os
7 import os.path
8+import sys
9
10 from dirspec import basedir
11 from twisted.internet import defer
12@@ -59,8 +60,27 @@
13
14 def get_activation_cmdline(name):
15 """Find the path to the executable callback."""
16- # TODO: We have to either use launchd to launch the different services
17- # on demand or us LaunchServices to handle running the app via an URL.
18+ if getattr(sys, "frozen", None) is not None:
19+ # We are running from a sub-package, so find the SSO Helper
20+ # app (a packaged version of ubuntu-sso-login) in the
21+ # Resources directory of the main .app package.
22+
23+ main_app_dir = "".join(__file__.partition(".app")[:-1])
24+ main_app_resources_dir = os.path.join(main_app_dir,
25+ "Contents",
26+ "Resources")
27+ if name == SSO_SERVICE_NAME:
28+ return os.path.join(main_app_resources_dir,
29+ "Ubuntu SSO Helper.app",
30+ "Contents", "MacOS",
31+ "ubuntu-sso-login")
32+ elif name == SD_SERVICE_NAME:
33+ return os.path.join(main_app_resources_dir,
34+ "UbuntuOne Syncdaemon.app",
35+ "Contents", "MacOS",
36+ "ubuntuone-syncdaemon")
37+ else:
38+ raise Exception("unknown service name %r" % name)
39
40 module_filename = ubuntu_sso.__file__
41 ubuntu_sso_pkg_dir = os.path.dirname(os.path.dirname(module_filename))
42
43=== modified file 'ubuntu_sso/main/tests/test_darwin.py'
44--- ubuntu_sso/main/tests/test_darwin.py 2012-04-30 16:15:46 +0000
45+++ ubuntu_sso/main/tests/test_darwin.py 2012-06-29 22:29:26 +0000
46@@ -16,10 +16,12 @@
47 """Darwin specific tests for the main module."""
48
49 import os
50+import sys
51
52 from dirspec import basedir
53 from twisted.internet import defer
54
55+import ubuntu_sso
56 from ubuntu_sso.main import darwin
57 from ubuntu_sso.tests import TestCase
58
59@@ -35,6 +37,43 @@
60 expected = os.path.join(basedir.xdg_cache_home, 'sso', 'ipc')
61 self.assertEqual(darwin.get_sso_domain_socket(), expected)
62
63+ def test_get_ac_cmdline_unfrozen_sso(self):
64+ """When unfrozen, cmdline should point to source tree /bin."""
65+ self.patch(ubuntu_sso, '__file__', "test/ubuntu_sso/__init__.py")
66+ cmd = darwin.get_activation_cmdline(darwin.SSO_SERVICE_NAME)
67+ self.assertEqual(cmd, "python test/bin/ubuntu-sso-login")
68+
69+ def test_get_ac_cmdline_unfrozen_sd(self):
70+ """When unfrozen, cmdline should point to source tree /bin."""
71+ self.patch(ubuntu_sso, '__file__', "test/ubuntu_sso/__init__.py")
72+ cmd = darwin.get_activation_cmdline(darwin.SD_SERVICE_NAME)
73+ expected = "python test/../ubuntuone-client/bin/ubuntuone-syncdaemon"
74+ self.assertEqual(cmd, expected)
75+
76+ def test_get_ac_cmdline_frozen_sso(self):
77+ """When frozen, cmdline should point to a sub-app path."""
78+ sys.frozen = True
79+ self.addCleanup(delattr, sys, "frozen")
80+ self.patch(darwin, "__file__",
81+ "/test/Main.app/ignore/the/rest")
82+ cmd = darwin.get_activation_cmdline(darwin.SSO_SERVICE_NAME)
83+ subapp_path = "Ubuntu SSO Helper.app/Contents/MacOS/ubuntu-sso-login"
84+ expected = os.path.join("/test/Main.app/Contents/Resources",
85+ subapp_path)
86+ self.assertEqual(cmd, expected)
87+
88+ def test_get_ac_cmdline_frozen_sd(self):
89+ """When frozen, cmdline should point to a sub-app path."""
90+ sys.frozen = True
91+ self.addCleanup(delattr, sys, "frozen")
92+ self.patch(darwin, "__file__",
93+ "/test/Main.app/ignore/the/rest")
94+ cmd = darwin.get_activation_cmdline(darwin.SD_SERVICE_NAME)
95+ sub = "UbuntuOne Syncdaemon.app/Contents/MacOS/ubuntuone-syncdaemon"
96+ expected = os.path.join("/test/Main.app/Contents/Resources",
97+ sub)
98+ self.assertEqual(cmd, expected)
99+
100
101 class DescriptionFactoryTestcase(TestCase):
102 """Test the factory."""
103
104=== modified file 'ubuntu_sso/main/tests/test_windows.py'
105--- ubuntu_sso/main/tests/test_windows.py 2012-06-27 20:16:56 +0000
106+++ ubuntu_sso/main/tests/test_windows.py 2012-06-29 22:29:26 +0000
107@@ -28,6 +28,8 @@
108 # files in the program, then also delete it here.
109 """Windows specific tests for the main module."""
110
111+import os
112+import sys
113 # pylint: disable=F0401
114 try:
115 import winreg
116@@ -111,8 +113,11 @@
117 uid_modulo * windows.SSO_PORT_ALLOCATION_STEP)
118 self._test_port_assignation(uid, expected_port)
119
120- def test_get_activation_cmdline(self):
121+ def test_get_activation_cmdline_frozen(self):
122 """Test the get_activation_cmdline method."""
123+ sys.frozen = True
124+ self.addCleanup(delattr, sys, "frozen")
125+
126 sample_value = "test 123"
127 self.patch(windows.winreg, "OpenKey",
128 lambda key, subkey: sample_value)
129@@ -122,6 +127,26 @@
130 perspective_broker.SSO_SERVICE_NAME)
131 self.assertEqual(sample_value, cmdline)
132
133+ def test_get_ac_cmdline_unfrozen_sso(self):
134+ """When unfrozen, cmdline should point to source tree /bin."""
135+ self.patch(sys, 'argv',
136+ [os.path.join('parts', 'ubuntu-sso-client',
137+ 'bin', 'ubuntu-sso-login-qt')])
138+ cmd = windows.get_activation_cmdline(windows.SSO_SERVICE_NAME)
139+ self.assertEqual(cmd,
140+ "python " + os.path.join('parts', 'ubuntu-sso-client',
141+ 'bin', 'ubuntu-sso-login'))
142+
143+ def test_get_ac_cmdline_unfrozen_sd(self):
144+ """When unfrozen, cmdline should point to source tree /bin."""
145+ self.patch(sys, 'argv',
146+ [os.path.join('parts', 'ubuntu-sso-client', 'bin',
147+ 'ubuntu-sso-login-qt')])
148+ cmd = windows.get_activation_cmdline('ubuntuone-syncdaemon')
149+ expected = "python " + os.path.join('parts', 'ubuntuone-client',
150+ 'bin', 'ubuntuone-syncdaemon')
151+ self.assertEqual(cmd, expected)
152+
153
154 class DescriptionFactoryTestcase(TestCase):
155 """Test the factory."""
156
157=== modified file 'ubuntu_sso/main/windows.py'
158--- ubuntu_sso/main/windows.py 2012-06-29 22:29:26 +0000
159+++ ubuntu_sso/main/windows.py 2012-06-29 22:29:26 +0000
160@@ -38,6 +38,8 @@
161
162 """
163
164+import os
165+import sys
166 # pylint: disable=F0401
167 import win32process
168 import win32security
169@@ -97,6 +99,10 @@
170 if name == SSO_SERVICE_NAME:
171 exe_name = 'ubuntu-sso-login'
172 else:
173+ parts_dir_l = dirname.split(os.path.sep)[:-2]
174+ parts_dirname = os.path.sep.join(parts_dir_l)
175+ dirname = os.path.join(parts_dirname,
176+ 'ubuntuone-client', 'bin')
177 exe_name = 'ubuntuone-syncdaemon'
178 value = os.path.join(dirname, exe_name)
179 return "python " + value

Subscribers

People subscribed via source and target branches