Пример #1
0
	def test_page_should_launch_tasks_to_populate_data(self):
		p = Page(url=some_url, owner=a_user)
		p.put()
		expect(page.Transform).process(p)
		expect(deferred).defer(page.task_extract_content, 'native', p.key())
		expect(deferred).defer(page.task_extract_content, 'view_text', p.key())
		p.start_content_population()
Пример #2
0
	def test_should_log_error_and_ignore_transforms_if_they_fail(self):
		modify(page).content_extractors = []

		p = Page(url=some_url, owner=a_user)

		expect(page.Transform).process(p).and_raise(page.TransformError("transform failed"))
		expect(p).error("transform failed")
		expect(deferred).defer(page.task_extract_content, *any_args).twice()

		p.start_content_population()
Пример #3
0
	def _add(self, user, url, success = None, force=False):
		new_page = None
		page = Page.find(user, url)
		if page is None:
			page = Page(owner=self.user(), url=url)
			page.start_content_population()
			new_page = page
		else:
			page.update(force=force)
			if force:
				new_page = page
		if page.errors:
			if not self.is_json():
				self._render_error(page)
		else:
			if success and new_page:
				success(new_page)
		return new_page