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
=== modified file 'tests/gtk3/test_catview.py'
--- tests/gtk3/test_catview.py 2012-09-07 08:16:25 +0000
+++ tests/gtk3/test_catview.py 2012-09-11 01:14:20 +0000
@@ -167,7 +167,7 @@
167 mock_network_state_is_connected):167 mock_network_state_is_connected):
168 # simulate no network available168 # simulate no network available
169 mock_network_state_is_connected.return_value = False169 mock_network_state_is_connected.return_value = False
170 self._populate_recommended_for_you_panel()170 self._opt_in_and_populate_recommended_for_you_panel()
171 self.assertEqual(self.rec_panel.spinner_notebook.get_current_page(),171 self.assertEqual(self.rec_panel.spinner_notebook.get_current_page(),
172 FramedHeaderBox.CONTENT)172 FramedHeaderBox.CONTENT)
173 # ensure that we are showing the network not available view173 # ensure that we are showing the network not available view
@@ -177,7 +177,7 @@
177 self.rec_panel.NO_NETWORK_RECOMMENDATIONS_TEXT)177 self.rec_panel.NO_NETWORK_RECOMMENDATIONS_TEXT)
178178
179 def test_recommended_for_you_display_recommendations(self):179 def test_recommended_for_you_display_recommendations(self):
180 self._populate_recommended_for_you_panel()180 self._opt_in_and_populate_recommended_for_you_panel()
181 # we fake the callback from the agent here181 # we fake the callback from the agent here
182 for_you = self.rec_panel.recommended_for_you_cat182 for_you = self.rec_panel.recommended_for_you_cat
183 for_you._recommend_me_result(None,183 for_you._recommend_me_result(None,
@@ -204,7 +204,7 @@
204 self.assertFalse(visible)204 self.assertFalse(visible)
205205
206 def test_recommended_for_you_display_recommendations_opted_in(self):206 def test_recommended_for_you_display_recommendations_opted_in(self):
207 self._populate_recommended_for_you_panel()207 self._opt_in_and_populate_recommended_for_you_panel()
208208
209 # we want to work in the "subcat" view209 # we want to work in the "subcat" view
210 self.notebook.next_page()210 self.notebook.next_page()
@@ -240,10 +240,8 @@
240 self.assertNotEqual(self._cat, None)240 self.assertNotEqual(self._cat, None)
241 self.assertEqual(self._cat.name, "Recommended For You in Internet")241 self.assertEqual(self._cat.name, "Recommended For You in Internet")
242 242
243 @unittest.skipIf(not get_config().recommender_uuid,
244 "this will only work when signed in")
245 def test_implicit_recommender_feedback(self):243 def test_implicit_recommender_feedback(self):
246 self._populate_recommended_for_you_panel()244 self._opt_in_and_populate_recommended_for_you_panel()
247 # we fake the callback from the agent here245 # we fake the callback from the agent here
248 for_you = self.rec_panel.recommended_for_you_cat246 for_you = self.rec_panel.recommended_for_you_cat
249 for_you._recommend_me_result(None,247 for_you._recommend_me_result(None,
@@ -278,7 +276,7 @@
278 # this test insures that we only provide feedback when installing276 # this test insures that we only provide feedback when installing
279 # items clicked to via the recommendations panel itself, and not277 # items clicked to via the recommendations panel itself, and not
280 # via the What's New or Top Rated panels278 # via the What's New or Top Rated panels
281 self._populate_recommended_for_you_panel()279 self._opt_in_and_populate_recommended_for_you_panel()
282 # we fake the callback from the agent here280 # we fake the callback from the agent here
283 for_you = self.rec_panel.recommended_for_you_cat281 for_you = self.rec_panel.recommended_for_you_cat
284 for_you._recommend_me_result(None,282 for_you._recommend_me_result(None,
@@ -317,10 +315,13 @@
317 # fired the implicit feedback call to the recommender315 # fired the implicit feedback call to the recommender
318 self.assertFalse(mock_post_implicit_feedback.called)316 self.assertFalse(mock_post_implicit_feedback.called)
319317
320 def _populate_recommended_for_you_panel(self):318 def _opt_in_and_populate_recommended_for_you_panel(self):
321 # click the opt-in button to initiate the process319 # click the opt-in button to initiate the process
322 self.rec_panel.opt_in_button.clicked()320 self.rec_panel.opt_in_button.clicked()
323 do_events()321 do_events()
322 # simulate a successful opt-in by setting the recommender_uuid
323 self.rec_panel.recommender_agent._set_recommender_uuid(
324 "35fd653e67b14482b7a8b632ea90d1b6")
324 # and update the recommended for you panel to load it up325 # and update the recommended for you panel to load it up
325 self.rec_panel._update_recommended_for_you_content()326 self.rec_panel._update_recommended_for_you_content()
326 do_events()327 do_events()

Subscribers

People subscribed via source and target branches