Merge lp:~dobey/unity-scope-click/fix-ppa-build into lp:unity-scope-click

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 110
Merged at revision: 110
Proposed branch: lp:~dobey/unity-scope-click/fix-ppa-build
Merge into: lp:unity-scope-click
Diff against target: 87 lines (+21/-4)
3 files modified
src/click-scope.vala (+3/-2)
src/rnrclient.vala (+2/-1)
src/test-click-webservice.vala (+16/-1)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/fix-ppa-build
Reviewer Review Type Date Requested Status
Mike McCracken (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+202157@code.launchpad.net

Commit message

Use a fake RNRClient to override network access in unit tests.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Mike McCracken (mikemc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/click-scope.vala'
2--- src/click-scope.vala 2014-01-13 22:24:22 +0000
3+++ src/click-scope.vala 2014-01-17 18:51:50 +0000
4@@ -1,5 +1,6 @@
5+/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
6 /*
7- * Copyright (C) 2013 Canonical, Ltd.
8+ * Copyright (C) 2013-2014 Canonical, Ltd.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12@@ -84,7 +85,7 @@
13 public ClickInterface click_if = new ClickInterface ();
14 public UbuntuoneCredentials u1creds = new UbuntuoneCredentials ();
15 public ClickWebservice webservice = new ClickWebservice ();
16- RNRClient rnrClient = new RNRClient();
17+ public RNRClient rnrClient = new RNRClient();
18
19 public ClickScope ()
20 {
21
22=== modified file 'src/rnrclient.vala'
23--- src/rnrclient.vala 2014-01-09 13:53:51 +0000
24+++ src/rnrclient.vala 2014-01-17 18:51:50 +0000
25@@ -90,7 +90,7 @@
26 * Returns: A Variant (list of dictionary) that containts the reviews.
27 *
28 */
29- public async Variant? get_reviews_by_filter(ReviewFilter filter) {
30+ public virtual async Variant? get_reviews_by_filter(ReviewFilter filter) {
31 Variant? ret = null;
32 WebserviceError failure = null;
33
34@@ -110,6 +110,7 @@
35 filter.packagename);
36 string response="";
37
38+ debug ("Getting reviews from URL: %s", url);
39 var message = new Soup.Message ("GET", url);
40 http_session.queue_message(message, (http_session, message) => {
41 if (message.status_code != Soup.KnownStatusCode.OK) {
42
43=== modified file 'src/test-click-webservice.vala'
44--- src/test-click-webservice.vala 2014-01-13 22:24:22 +0000
45+++ src/test-click-webservice.vala 2014-01-17 18:51:50 +0000
46@@ -1,5 +1,6 @@
47+/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
48 /*
49- * Copyright (C) 2013 Canonical, Ltd.
50+ * Copyright (C) 2013-2014 Canonical, Ltd.
51 *
52 * This program is free software; you can redistribute it and/or modify
53 * it under the terms of the GNU General Public License as published by
54@@ -184,6 +185,18 @@
55 }
56 }
57
58+ class FakeRNRClient : RNRClient {
59+ public override async Variant? get_reviews_by_filter (ReviewFilter filter) {
60+ var parser = new Json.Parser ();
61+ try {
62+ parser.load_from_data (FAKE_RNR_REVIEW_RESULTS);
63+ } catch (GLib.Error e) {
64+ error ("Failed to parse RNR JSON: %s", e.message);
65+ }
66+ return convertJSONtoVariant (parser);
67+ }
68+ }
69+
70 class FakeSignedDownloadOK : SignedDownload {
71 public async override new GLib.ObjectPath start_download (string uri, string app_id) throws DownloadError {
72 return new GLib.ObjectPath (FAKE_OBJECT_PATH);
73@@ -404,6 +417,7 @@
74 MainLoop mainloop = new MainLoop ();
75 ClickScope scope = new ClickScope ();
76 scope.webservice = new FakeClickWebservice ();
77+ scope.rnrClient = new FakeRNRClient ();
78 var metadata = new HashTable<string, Variant> (str_hash, str_equal);
79 metadata.insert(METADATA_APP_ID, new GLib.Variant.string(FAKE_APP_ID));
80 var fake_result = Unity.ScopeResult.create("", "", 0,
81@@ -445,6 +459,7 @@
82 MainLoop mainloop = new MainLoop ();
83 ClickScope scope = new ClickScope ();
84 scope.webservice = new FakeClickWebservice ();
85+ scope.rnrClient = new FakeRNRClient ();
86 scope.click_if = new FakeClickInterface ();
87 ((FakeClickInterface) scope.click_if).fake_can_uninstall = can_uninstall;
88

Subscribers

People subscribed via source and target branches

to all changes: