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() 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), [])
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), [])
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") # "2" is a multimedia query # see ./test/data/desktop/software-center.menu recommends_cat = RecommendedForYouCategory(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) print recommendations_in_cat self.assertNotEqual(recommendations_in_cat, [])
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, [])