Пример #1
0
	def test_search_and_choose(self):
		""" Whole process """
		ep_finder = NetworkEpisodeVideoFinder()
		def print_results(results):
			""" presentation callback"""
			#print("Résultats {}".format(len(results)))
			pass
		def catch_err(res):
			""" error callback """
			print "err catched {}".format(res)
		def choose(res):
			""" choose callback, actually launches a dl
			"""

			info("res {}".format(res))
			info( "Choosing {}".format(ep_finder.candidates[0]))
			ep_finder.on_chosen_launch_dl(ep_finder.candidates[0])
			info ("dl_launched ?")
			return True

		final_test = OnEventDeferred(ep_finder, "download_launched")
		final_test.add_error_event(ep_finder, "download_not_launched")

		candidates_found = OnEventDeferred(ep_finder, "candidates_found")\
				.addCallback(choose).addErrback(catch_err)
		ep_find = ep_finder.search_newep(self.episode)\
				.addCallback(print_results)
		return final_test.addBoth(catch_err)
Пример #2
0
	def test_object_client(self):
		""" Testing the object client 'NetworkEpisodeVideoFinder'
		as a whole"""
		finder = NetworkEpisodeVideoFinder()
		finder.search_newep(self.episode)
		
		founded = OnEventDeferred(finder, "candidates_found")\
				.addCallback(self.set_candidates)
		def choose(res):
			""" Returns a candidate """
			info("res passed to choose :{}".format(res))
			return finder.candidates[0]

		def launch(choice):
			""" launches the dl"""
			return finder.on_chosen_launch_dl(choice)

		info("waiting for results ...")

		return founded.addCallback(choose).addCallback(launch)