Пример #1
0
    def test_can_wait_when_urls_and_no_timeout(self, logging_mock):
        otto = TornadoOctopus(cache=False, auto_start=True)
        otto.ioloop = Mock()
        otto.running_urls = 10

        otto.wait(0)

        logging_mock.assert_calls('Waiting for urls to be retrieved.')
Пример #2
0
    def test_can_wait_when_urls_and_timeout(self):
        otto = TornadoOctopus(cache=False, auto_start=True)
        otto.ioloop = Mock()
        otto.running_urls = 10

        otto.wait()

        expect(otto.ioloop.set_blocking_signal_threshold.called)
Пример #3
0
    def test_can_wait_when_urls_and_no_timeout(self, logging_mock):
        otto = TornadoOctopus(cache=False, auto_start=True)
        otto.ioloop = Mock()
        otto.running_urls = 10

        otto.wait(0)

        logging_mock.assert_calls('Waiting for urls to be retrieved.')
Пример #4
0
    def test_can_wait_when_urls_and_timeout(self):
        otto = TornadoOctopus(cache=False, auto_start=True)
        otto.ioloop = Mock()
        otto.running_urls = 10

        otto.wait()

        expect(otto.ioloop.set_blocking_signal_threshold.called)
Пример #5
0
    def test_handle_request_when_queue_has_no_items_but_running_urls(self):
        otto = TornadoOctopus(cache=True, auto_start=True)
        otto.response_cache = Mock()
        otto.running_urls = 10

        response = self.get_response()

        callback = Mock()

        handle_request = otto.handle_request('some url', callback)

        handle_request(response)

        expect(otto.running_urls).to_equal(9)
        expect(callback.called).to_be_true()
        expect(otto.response_cache.put.called).to_be_true()
Пример #6
0
    def test_handle_request_when_queue_has_no_items_but_running_urls(self):
        otto = TornadoOctopus(cache=True, auto_start=True)
        otto.response_cache = Mock()
        otto.running_urls = 10

        response = self.get_response()

        callback = Mock()

        handle_request = otto.handle_request('some url', callback)

        handle_request(response)

        expect(otto.running_urls).to_equal(9)
        expect(callback.called).to_be_true()
        expect(otto.response_cache.put.called).to_be_true()