Merge lp:~gary-lasker/software-center/recommender-test-fix into lp:software-center

Proposed by Gary Lasker
Status: Merged
Merged at revision: 3159
Proposed branch: lp:~gary-lasker/software-center/recommender-test-fix
Merge into: lp:software-center
Diff against target: 66 lines (+9/-8)
1 file modified
tests/gtk3/test_catview.py (+9/-8)
To merge this branch: bzr merge lp:~gary-lasker/software-center/recommender-test-fix
Reviewer Review Type Date Requested Status
Michael Vogt Approve
Review via email: mp+123669@code.launchpad.net

Commit message

* lp:~gary-lasker/software-center/recommender-test-fix:
    - update the recommender feedback unit test to work on systems
      that are not opted-in

Description of the change

This branch fixes the test_implicit_recommender_feedback unit test so that it will work on systems that are not actually opted-in to the recommendations service. I've removed the corresponding unittest.skipIf for this test. Note that this fix also takes care of the "ValidationException: Argument 'uuid' must match pattern '[\dabcdef]{32}$'" exceptions that are thrown for some of the other tests.

Thank you for your review!

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks, looks good.

The test failed for me when running it initially with the following error:
======================================================================
FAIL: test_recommended_for_you_spinner_display (__main__.RecommendationsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/gtk3/test_catview.py", line 162, in test_recommended_for_you_spinner_display
    self.rec_panel.recommended_for_you_content.get_property("visible"))
AssertionError: False is not true

----------------------------------------------------------------------
Ran 9 tests in 19.177s

but subsequent runs worked, it seems to be random, maybe 1 out 5. And I doubt its releated
to this branch so I will merge it. But it would be nice if that could be investigated.

review: Approve
Revision history for this message
Gary Lasker (gary-lasker) wrote :

I have seen this test failure myself for a while now, for me it happens about one out of 10 runs, and I just haven't had the chance to investigate it. Indeed, it is completely unrelated to anything in this branch. It seems like just a race issue in the test as I personally have not seen problems in this area in the real code.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/gtk3/test_catview.py'
2--- tests/gtk3/test_catview.py 2012-09-07 08:16:25 +0000
3+++ tests/gtk3/test_catview.py 2012-09-11 01:14:20 +0000
4@@ -167,7 +167,7 @@
5 mock_network_state_is_connected):
6 # simulate no network available
7 mock_network_state_is_connected.return_value = False
8- self._populate_recommended_for_you_panel()
9+ self._opt_in_and_populate_recommended_for_you_panel()
10 self.assertEqual(self.rec_panel.spinner_notebook.get_current_page(),
11 FramedHeaderBox.CONTENT)
12 # ensure that we are showing the network not available view
13@@ -177,7 +177,7 @@
14 self.rec_panel.NO_NETWORK_RECOMMENDATIONS_TEXT)
15
16 def test_recommended_for_you_display_recommendations(self):
17- self._populate_recommended_for_you_panel()
18+ self._opt_in_and_populate_recommended_for_you_panel()
19 # we fake the callback from the agent here
20 for_you = self.rec_panel.recommended_for_you_cat
21 for_you._recommend_me_result(None,
22@@ -204,7 +204,7 @@
23 self.assertFalse(visible)
24
25 def test_recommended_for_you_display_recommendations_opted_in(self):
26- self._populate_recommended_for_you_panel()
27+ self._opt_in_and_populate_recommended_for_you_panel()
28
29 # we want to work in the "subcat" view
30 self.notebook.next_page()
31@@ -240,10 +240,8 @@
32 self.assertNotEqual(self._cat, None)
33 self.assertEqual(self._cat.name, "Recommended For You in Internet")
34
35- @unittest.skipIf(not get_config().recommender_uuid,
36- "this will only work when signed in")
37 def test_implicit_recommender_feedback(self):
38- self._populate_recommended_for_you_panel()
39+ self._opt_in_and_populate_recommended_for_you_panel()
40 # we fake the callback from the agent here
41 for_you = self.rec_panel.recommended_for_you_cat
42 for_you._recommend_me_result(None,
43@@ -278,7 +276,7 @@
44 # this test insures that we only provide feedback when installing
45 # items clicked to via the recommendations panel itself, and not
46 # via the What's New or Top Rated panels
47- self._populate_recommended_for_you_panel()
48+ self._opt_in_and_populate_recommended_for_you_panel()
49 # we fake the callback from the agent here
50 for_you = self.rec_panel.recommended_for_you_cat
51 for_you._recommend_me_result(None,
52@@ -317,10 +315,13 @@
53 # fired the implicit feedback call to the recommender
54 self.assertFalse(mock_post_implicit_feedback.called)
55
56- def _populate_recommended_for_you_panel(self):
57+ def _opt_in_and_populate_recommended_for_you_panel(self):
58 # click the opt-in button to initiate the process
59 self.rec_panel.opt_in_button.clicked()
60 do_events()
61+ # simulate a successful opt-in by setting the recommender_uuid
62+ self.rec_panel.recommender_agent._set_recommender_uuid(
63+ "35fd653e67b14482b7a8b632ea90d1b6")
64 # and update the recommended for you panel to load it up
65 self.rec_panel._update_recommended_for_you_content()
66 do_events()

Subscribers

People subscribed via source and target branches