def test_markers_and_context_complete(self, mark, context_from_id,
                                          check_markers):
        """Ensure if all markers are complete that True is returned and
        nothing else is done.
        """
        async = Async('foo')
        async.update_options(context_id='contextid')

        complete_event = Mock()
        context = Context(id="contextid",
                          callbacks={'complete': complete_event})

        context_from_id.return_value = context

        marker = FuriousCompletionMarker(id="contextid", complete=True)
        marker.put()

        check_markers.return_value = True, False
        mark.return_value = True

        result = _completion_checker(async.id, async.context_id)

        self.assertTrue(result)

        self.assertFalse(complete_event.start.called)

        marker.key.delete()
    def test_no_context_id(self, context_from_id, check_markers):
        """Ensure if no context id that nothing happens.
        """
        result = _completion_checker("1", None)

        self.assertIsNone(result)

        self.assertFalse(context_from_id.called)

        self.assertFalse(check_markers.start.called)
    def test_no_context_id(self, context_from_id, check_markers):
        """Ensure if no context id that nothing happens.
        """
        result = _completion_checker("1", None)

        self.assertIsNone(result)

        self.assertFalse(context_from_id.called)

        self.assertFalse(check_markers.start.called)
    def test_markers_complete(self, mark, context_from_id, check_markers):
        """Ensure if all markers are complete that True is returned and the
        completion handler and cleanup tasks are triggered.
        """
        complete_event = Mock()
        context = Context(id="contextid",
                          callbacks={'complete': complete_event})

        context_from_id.return_value = context

        check_markers.return_value = True, False
        mark.return_value = True

        async = Async('foo')
        async.update_options(context_id='contextid')

        result = _completion_checker(async.id, async.context_id)

        self.assertTrue(result)

        complete_event.start.assert_called_once_with()