Merge lp:~mvo/software-center/reinstall-previous-purchase-token-fix into lp:software-center

Proposed by Michael Vogt on 2012-10-11
Status: Merged
Merged at revision: 3230
Proposed branch: lp:~mvo/software-center/reinstall-previous-purchase-token-fix
Merge into: lp:software-center
Diff against target: 57 lines (+22/-2)
2 files modified
softwarecenter/ui/gtk3/session/appmanager.py (+5/-1)
tests/gtk3/test_appmanager.py (+17/-1)
To merge this branch: bzr merge lp:~mvo/software-center/reinstall-previous-purchase-token-fix
Reviewer Review Type Date Requested Status
Dave Morley (community) reinstalled an app using this branch Approve on 2012-10-11
software-store-developers 2012-10-11 Pending
Review via email: mp+129166@code.launchpad.net

Description of the change

This branch fixes reinstall previous purchases that contain a system wide license key. LP: #1065481

To post a comment you must log in.
3231. By Michael Vogt on 2012-10-11

tests/gtk3/test_appmanager.py: ensure that the ApplicationManager has a valid oauth token

Dave Morley (davmor2) wrote :

I've tested this is functioning on a real app reinstall. Main doesn't work, however using this branch does. Indicating that this branch fixes the issue for reinstalling applications that have License Keys.

review: Approve (reinstalled an app using this branch)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/ui/gtk3/session/appmanager.py'
2--- softwarecenter/ui/gtk3/session/appmanager.py 2012-09-14 15:01:37 +0000
3+++ softwarecenter/ui/gtk3/session/appmanager.py 2012-10-11 12:35:33 +0000
4@@ -26,6 +26,7 @@
5
6 from gi.repository import GObject
7
8+from softwarecenter.backend.ubuntusso import UbuntuSSO
9 from softwarecenter.enums import AppActions
10 from softwarecenter.db import DebFileApplication
11 from softwarecenter.distro import get_current_arch, get_distro
12@@ -59,7 +60,10 @@
13 self.backend = backend
14 self.distro = get_distro()
15 self.icons = icons
16- self.oauth_token = ""
17+ # its ok to use the sync version here to get the token, this is
18+ # very quick
19+ helper = UbuntuSSO()
20+ self.oauth_token = helper.find_oauth_token_sync()
21
22 def _globalise_instance(self):
23 global _appmanager
24
25=== modified file 'tests/gtk3/test_appmanager.py'
26--- tests/gtk3/test_appmanager.py 2012-08-20 09:09:45 +0000
27+++ tests/gtk3/test_appmanager.py 2012-10-11 12:35:33 +0000
28@@ -1,6 +1,9 @@
29 import unittest
30
31-from mock import Mock
32+from mock import (
33+ Mock,
34+ patch,
35+ )
36
37 from tests.utils import (
38 do_events,
39@@ -76,5 +79,18 @@
40 def _on_purchase_requested(self, *args):
41 self._purchase_requested_signal = True
42
43+ def test_appmanager_requests_oauth_token(self):
44+ oauth_token = { "moo": "bar",
45+ "lala": "la",
46+ }
47+ # reset the global appmanager
48+ softwarecenter.ui.gtk3.session.appmanager._appmanager = None
49+ with patch("softwarecenter.ui.gtk3.session.appmanager.UbuntuSSO"
50+ ".find_oauth_token_sync") as m:
51+ m.return_value = oauth_token
52+ app_manager = ApplicationManager(self.db, self.backend, self.icons)
53+ self.assertEqual(app_manager.oauth_token, oauth_token)
54+
55+
56 if __name__ == "__main__":
57 unittest.main()

Subscribers

People subscribed via source and target branches