Merge lp:~dobey/go-unityscopes/login-item into lp:go-unityscopes/v2

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 82
Merged at revision: 78
Proposed branch: lp:~dobey/go-unityscopes/login-item
Merge into: lp:go-unityscopes/v2
Diff against target: 72 lines (+52/-0)
3 files modified
accounts.go (+17/-0)
accounts_test.go (+29/-0)
debian/changelog (+6/-0)
To merge this branch: bzr merge lp:~dobey/go-unityscopes/login-item
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+309353@code.launchpad.net

Commit message

Add RegisterAccountLoginWidget method and a test for it.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'accounts.go'
2--- accounts.go 2015-03-02 14:44:19 +0000
3+++ accounts.go 2016-10-26 14:26:58 +0000
4@@ -39,3 +39,20 @@
5 LoginFailedAction: failedAction,
6 })
7 }
8+
9+// RegisterAccountLoginWidget configures a widget such that the dash
10+// will attempt to log in to the account identified by (serviceName,
11+// serviceType, providerName).
12+//
13+// On success, the dash will perform the action specified by
14+// passedAction. On failure, it will use failedAction.
15+func RegisterAccountLoginWidget(widget *PreviewWidget, serviceName, serviceType, providerName string, passedAction, failedAction PostLoginAction) {
16+ widget.AddAttributeValue("online_account_details", map[string]interface{}{
17+ "scope_id": "",
18+ "service_name": serviceName,
19+ "service_type": serviceType,
20+ "provider_name": providerName,
21+ "login_passed_action": passedAction,
22+ "login_failed_action": failedAction,
23+ })
24+}
25
26=== added file 'accounts_test.go'
27--- accounts_test.go 1970-01-01 00:00:00 +0000
28+++ accounts_test.go 2016-10-26 14:26:58 +0000
29@@ -0,0 +1,29 @@
30+package scopes_test
31+
32+import (
33+ . "gopkg.in/check.v1"
34+ "launchpad.net/go-unityscopes/v2"
35+)
36+
37+func (s *S) TestRegisterAccountLoginWidget(c *C) {
38+ widget := scopes.NewPreviewWidget("buttons", "actions")
39+ widget.AddAttributeValue("actions", map[string]interface{}{
40+ "id": "install-snap",
41+ "label": "Install",
42+ })
43+ scopes.RegisterAccountLoginWidget(&widget,
44+ "ubuntuone", "ubuntuone", "ubuntuone",
45+ scopes.PostLoginContinueActivation,
46+ scopes.PostLoginDoNothing)
47+
48+ result, ok := widget["online_account_details"]
49+ c.Check(ok, Equals, true)
50+ c.Check(result, DeepEquals, map[string]interface{}{
51+ "scope_id": "",
52+ "service_name": "ubuntuone",
53+ "service_type": "ubuntuone",
54+ "provider_name": "ubuntuone",
55+ "login_passed_action": scopes.PostLoginContinueActivation,
56+ "login_failed_action": scopes.PostLoginDoNothing,
57+ })
58+}
59
60=== modified file 'debian/changelog'
61--- debian/changelog 2016-10-14 20:06:46 +0000
62+++ debian/changelog 2016-10-26 14:26:58 +0000
63@@ -1,3 +1,9 @@
64+go-unityscopes (1.0.1) UNRELEASED; urgency=medium
65+
66+ * Add API for registering widget as login item. (LP: #1636853)
67+
68+ -- Rodney Dawes <rodney.dawes@canonical.com> Wed, 26 Oct 2016 10:14:54 -0400
69+
70 go-unityscopes (1.0+16.10.20161014-0ubuntu1) yakkety; urgency=medium
71
72 * Initial packaging of go-unityscopes.

Subscribers

People subscribed via source and target branches

to all changes: