Esempio n. 1
0
 def test_implicit_recommender_feedback_recommendations_panel_only(self):
     # this test insures that we only provide feedback when installing
     # items clicked to via the recommendations panel itself, and not
     # via the What's New or Top Rated panels
     self._opt_in_and_populate_recommended_for_you_panel()
     # we fake the callback from the agent here
     for_you = self.rec_panel.recommended_for_you_cat
     for_you._recommend_me_result(None,
         make_recommender_agent_recommend_me_dict())
     do_events()
     
     post_implicit_feedback_fn = ('softwarecenter.ui.gtk3.widgets'
                                  '.recommendations.RecommenderAgent'
                                  '.post_implicit_feedback')
     with patch(post_implicit_feedback_fn) as mock_post_implicit_feedback:
         # we want to grab the app that is activated, it will be in
         # self._app after the app is activated on the tile click
         self.lobby.top_rated.connect("application-activated",
                                       self._on_application_activated)
         # click a tile in the Top Rated section of the lobby
         self._click_first_tile_in_panel(self.lobby.top_rated_frame)
         # simulate installing the application
         self._simulate_install_events(self._app)
         # and verify that after the install has completed we have *not*
         # fired the implicit feedback call to the recommender service
         self.assertFalse(mock_post_implicit_feedback.called)
Esempio n. 2
0
 def test_implicit_recommender_feedback_on_item_viewed(self):
     self._opt_in_and_populate_recommended_for_you_panel()
     # we fake the callback from the agent here
     for_you = self.rec_panel.recommended_for_you_cat
     for_you._recommend_me_result(None,
         make_recommender_agent_recommend_me_dict())
     do_events()
     
     post_implicit_feedback_fn = ('softwarecenter.ui.gtk3.widgets'
                                  '.recommendations.RecommenderAgent'
                                  '.post_implicit_feedback')
     with patch(post_implicit_feedback_fn) as mock_post_implicit_feedback:
         # we want to grab the app that is activated, it will be in
         # self._app after the app is activated on the tile click
         self.rec_panel.recommended_for_you_content.connect(
                                         "application-activated",
                                         self._on_application_activated)
         # click a recommendation in the lobby
         self._click_first_tile_in_panel(self.rec_panel)
         # and verify that upon selecting a recommended app we have fired
         # the implicit feedback call to the recommender with the correct
         # arguments
         mock_post_implicit_feedback.assert_called_with(
                 self._app.pkgname,
                 RecommenderFeedbackActions.VIEWED)
Esempio n. 3
0
 def test_recommends_category(self, AgentMockCls):
     # ensure we use the same instance in test and code
     agent_mock_instance = AgentMockCls.return_value
     recommends_cat = RecommendedForYouCategory(self.db)
     docids = recommends_cat.get_documents(self.db)
     self.assertEqual(docids, [])
     self.assertTrue(agent_mock_instance.query_recommend_me.called)
     # ensure we get a query when the callback is called
     recommends_cat._recommend_me_result(
         None, make_recommender_agent_recommend_me_dict())
     self.assertNotEqual(recommends_cat.get_documents(self.db), [])
Esempio n. 4
0
 def test_recommends_category(self, AgentMockCls):
     # ensure we use the same instance in test and code
     agent_mock_instance = AgentMockCls.return_value
     recommends_cat = RecommendedForYouCategory(self.db)
     docids = recommends_cat.get_documents(self.db)
     self.assertEqual(docids, [])
     self.assertTrue(agent_mock_instance.query_recommend_me.called)
     # ensure we get a query when the callback is called
     recommends_cat._recommend_me_result(
                             None,
                             make_recommender_agent_recommend_me_dict())
     self.assertNotEqual(recommends_cat.get_documents(self.db), [])
Esempio n. 5
0
 def test_recommends_in_category_category(self, AgentMockCls):
     # ensure we use the same instance in test and code
     parser = CategoriesParser(self.db)
     cats = parser.parse_applications_menu(DATA_DIR)
     # "2" is a multimedia query
     #     see ./test/data/desktop/software-center.menu
     recommends_cat = RecommendedForYouCategory(self.db,
                                                subcategory=cats[2])
     # ensure we get a query when the callback is called
     recommends_cat._recommend_me_result(
         None, make_recommender_agent_recommend_me_dict())
     recommendations_in_cat = recommends_cat.get_documents(self.db)
     self.assertNotEqual(recommendations_in_cat, [])
Esempio n. 6
0
 def test_recommends_in_category_category(self, AgentMockCls):
     # ensure we use the same instance in test and code
     parser = CategoriesParser(self.db)
     cats = parser.parse_applications_menu(DATA_DIR)
     # "2" is a multimedia query
     #     see ./test/data/desktop/software-center.menu
     recommends_cat = RecommendedForYouCategory(self.db,
                                                subcategory=cats[2])
     # ensure we get a query when the callback is called
     recommends_cat._recommend_me_result(
                             None,
                             make_recommender_agent_recommend_me_dict())
     recommendations_in_cat = recommends_cat.get_documents(self.db)
     self.assertNotEqual(recommendations_in_cat, [])
Esempio n. 7
0
 def test_recommended_for_you_display_recommendations(self):
     self._opt_in_and_populate_recommended_for_you_panel()
     # we fake the callback from the agent here
     for_you = self.rec_panel.recommended_for_you_cat
     for_you._recommend_me_result(None,
         make_recommender_agent_recommend_me_dict())
     self.assertNotEqual(for_you.get_documents(self.db), [])
     self.assertEqual(self.rec_panel.spinner_notebook.get_current_page(),
                      SpinnerNotebook.CONTENT_PAGE)
     do_events()
     # test clicking recommended_for_you More button
     self.lobby.connect("category-selected", self._on_category_selected)
     self.rec_panel.more.clicked()
     # this is delayed for some reason so we need to sleep here
     do_events_with_sleep()
     self.assertNotEqual(self._cat, None)
     self.assertEqual(self._cat.name, "Recommended For You")
Esempio n. 8
0
    def test_recommended_for_you_display_recommendations_opted_in(self):
        self._opt_in_and_populate_recommended_for_you_panel()

        # we want to work in the "subcat" view
        self.notebook.next_page()

        rec_cat_panel = self.subcat_view.recommended_for_you_in_cat
        rec_cat_panel._update_recommended_for_you_content()
        do_events()
        # we fake the callback from the agent here
        rec_cat_panel.recommended_for_you_cat._recommend_me_result(
                                None,
                                make_recommender_agent_recommend_me_dict())
        result_docs = rec_cat_panel.recommended_for_you_cat.get_documents(
            self.db)
        self.assertNotEqual(result_docs, [])
        # check that we are getting the correct number of results,
        # corresponding to the following Internet items:
        #   Mangler, Midori, Midori Private Browsing, Psi
        self.assertTrue(len(result_docs) == 4)
        self.assertEqual(rec_cat_panel.spinner_notebook.get_current_page(),
                         SpinnerNotebook.CONTENT_PAGE)
        # check that the tiles themselves are visible
        self.assertTrue(rec_cat_panel.recommended_for_you_content.get_property(
            "visible"))
        self.assertTrue(rec_cat_panel.recommended_for_you_content.get_children(
            )[0].title.get_property("visible"))

        # test clicking recommended_for_you More button
        self.subcat_view.connect(
            "category-selected", self._on_category_selected)
        rec_cat_panel.more.clicked()
        # this is delayed for some reason so we need to sleep here
        do_events_with_sleep()
        self.assertNotEqual(self._cat, None)
        self.assertEqual(self._cat.name, "Recommended For You in Internet")