本文整理匯總了Python中softwarecenter.backend.recagent.RecommenderAgent.post_submit_profile方法的典型用法代碼示例。如果您正苦於以下問題:Python RecommenderAgent.post_submit_profile方法的具體用法?Python RecommenderAgent.post_submit_profile怎麽用?Python RecommenderAgent.post_submit_profile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類softwarecenter.backend.recagent.RecommenderAgent
的用法示例。
在下文中一共展示了RecommenderAgent.post_submit_profile方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: disabled_test_recagent_post_submit_profile
# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import post_submit_profile [as 別名]
def disabled_test_recagent_post_submit_profile(self):
# NOTE: This requires a working recommender host that is reachable
recommender_agent = RecommenderAgent()
recommender_agent.connect("submit-profile-finished", self.on_query_done)
recommender_agent.connect("error", self.on_query_error)
db = get_test_db()
recommender_agent.post_submit_profile(db)
self.loop.run()
self.assertFalse(self.error)
示例2: test_mocked_recagent_post_submit_profile
# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import post_submit_profile [as 別名]
def test_mocked_recagent_post_submit_profile(self, mock_spawn_helper_run):
recommender_agent = RecommenderAgent()
recommender_agent._calc_profile_id = lambda profile: "i-am-random"
db = get_test_db()
recommender_agent.post_submit_profile(db)
args, kwargs = mock_spawn_helper_run.call_args
# ensure we have packages in the package list and the
# kwargs have the names we expect
self.assertNotEqual(kwargs['data'][0]['package_list'], [])
示例3: test_mocked_recagent_post_submit_profile
# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import post_submit_profile [as 別名]
def test_mocked_recagent_post_submit_profile(self, mock_spawn_helper_run):
def _patched_on_submit_profile_data(*args, **kwargs):
piston_submit_profile = {}
recommender_agent.emit("submit-profile-finished",
piston_submit_profile)
mock_spawn_helper_run.side_effect = _patched_on_submit_profile_data
recommender_agent = RecommenderAgent()
recommender_agent.connect("submit-profile-finished", self.on_query_done)
recommender_agent.connect("error", self.on_query_error)
recommender_agent._calc_profile_id = lambda profile: "i-am-random"
db = get_test_db()
recommender_agent.post_submit_profile(db)
self.assertFalse(self.error)
args, kwargs = mock_spawn_helper_run.call_args
self.assertNotEqual(kwargs['data'][0]['package_list'], [])
示例4: RealTestRecommenderAgent
# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import post_submit_profile [as 別名]
class RealTestRecommenderAgent(unittest.TestCase):
""" tests the recommender agent """
@unittest.skipIf(os.getuid() == 0,
"this is not supported running as root")
def setUp(self):
self.loop = GLib.MainLoop(GLib.main_context_default())
self.error = False
if "SOFTWARE_CENTER_RECOMMENDER_HOST" in os.environ:
orig_host = os.environ.get("SOFTWARE_CENTER_RECOMMENDER_HOST")
self.addCleanup(os.environ.__setitem__,
"SOFTWARE_CENTER_RECOMMENDER_HOST", orig_host)
else:
self.addCleanup(os.environ.pop, "SOFTWARE_CENTER_RECOMMENDER_HOST")
server = "https://rec.staging.ubuntu.com"
os.environ["SOFTWARE_CENTER_RECOMMENDER_HOST"] = server
# most tests need it
self.recommender_agent = RecommenderAgent()
self.recommender_agent.connect("error", self.on_query_error)
def on_query_done(self, recagent, data):
#print "query done, data: '%s'" % data
self.loop.quit()
self.error = False
self.error_msg = ""
def on_query_error(self, recagent, error):
#print "query error received: ", error
self.loop.quit()
self.error = True
self.error_msg = error
def assertServerReturnsWithNoError(self):
self.loop.run()
self.assertFalse(self.error, "got error: '%s'" % self.error_msg)
def test_recagent_query_server_status(self):
self.recommender_agent.connect("server-status", self.on_query_done)
self.recommender_agent.query_server_status()
self.assertServerReturnsWithNoError()
@unittest.skip("server returns 401")
def test_recagent_post_submit_profile(self):
# NOTE: This requires a working recommender host that is reachable
db = get_test_db()
self.recommender_agent.connect(
"submit-profile-finished", self.on_query_done)
self.recommender_agent.post_submit_profile(db)
self.assertServerReturnsWithNoError()
#print mock_request._post
@unittest.skip("server returns 401")
def test_recagent_query_submit_anon_profile(self):
self.recommender_agent.connect(
"submit-anon-profile-finished", self.on_query_done)
self.recommender_agent.post_submit_anon_profile(
uuid="xxxyyyzzz",
installed_packages=["pitivi", "fretsonfire"],
extra="")
self.assertServerReturnsWithNoError()
@unittest.skip("server returns 401")
def test_recagent_query_profile(self):
self.recommender_agent.connect("profile", self.on_query_done)
self.recommender_agent.query_profile(pkgnames=["pitivi", "fretsonfire"])
self.assertServerReturnsWithNoError()
@unittest.skip("server returns 401")
def test_recagent_query_recommend_me(self):
self.recommender_agent.connect("recommend-me", self.on_query_done)
self.recommender_agent.query_recommend_me()
self.assertServerReturnsWithNoError()
def test_recagent_query_recommend_app(self):
self.recommender_agent.connect("recommend-app", self.on_query_done)
self.recommender_agent.query_recommend_app("pitivi")
self.assertServerReturnsWithNoError()
def test_recagent_query_recommend_all_apps(self):
self.recommender_agent.connect("recommend-all-apps", self.on_query_done)
self.recommender_agent.query_recommend_all_apps()
self.assertServerReturnsWithNoError()
def test_recagent_query_recommend_top(self):
self.recommender_agent.connect("recommend-top", self.on_query_done)
self.recommender_agent.query_recommend_top()
self.assertServerReturnsWithNoError()
def test_recagent_query_error(self):
# NOTE: This tests the error condition itself! it simply forces an error
# 'cuz there definitely isn't a server here :)
fake_server = "https://test-no-server-here.staging.ubuntu.com"
os.environ["SOFTWARE_CENTER_RECOMMENDER_HOST"] = fake_server
recommender_agent = RecommenderAgent()
recommender_agent.connect("recommend-top", self.on_query_done)
recommender_agent.connect("error", self.on_query_error)
recommender_agent.query_recommend_top()
self.loop.run()
self.assertTrue(self.error)
#.........這裏部分代碼省略.........