Пример #1
0
 def test_process_item_sets_exception_on_failure(self):
     monitor = MakePresentationReadyMonitor(self._db,
                                            [self.success, self.failure])
     monitor.process_item(self.work)
     eq_("Provider(s) failed: %s" % self.failure.SERVICE_NAME,
         self.work.presentation_ready_exception)
     eq_(False, self.work.presentation_ready)
Пример #2
0
    def test_process_item_sets_presentation_ready_on_success(self):
        # Create a monitor that doesn't need to do anything.
        monitor = MakePresentationReadyMonitor(self._db, [])
        monitor.process_item(self.work)

        # When it's done doing nothing, it sets the work as
        # presentation-ready.
        eq_(None, self.work.presentation_ready_exception)
        eq_(True, self.work.presentation_ready)
Пример #3
0
 def test_prepare_raises_exception_with_failing_providers(self):
     monitor = MakePresentationReadyMonitor(
         self._db, [self.success, self.failure]
     )
     assert_raises_regexp(
         CoverageProvidersFailed,
         self.failure.service_name,
         monitor.prepare, self.work
     )
Пример #4
0
    def test_prepare_does_not_call_irrelevant_provider(self):

        monitor = MakePresentationReadyMonitor(self._db, [self.success])
        result = monitor.prepare(self.work)

        # There were no failures.
        eq_([], result)

        # The 'success' monitor ran.
        eq_([self.work.presentation_edition.primary_identifier],
            self.success.attempts)

        # The 'failure' monitor did not. (If it had, it would have
        # failed.)
        eq_([], self.failure.attempts)

        # The work has not been set to presentation ready--that's
        # handled in process_item().
        eq_(False, self.work.presentation_ready)