Пример #1
0
 def test_return_body_if_valid(self):
     response_mock = ResponseMock(body='body', code=200)
     callback_mock = mock.Mock()
     ctx = Context(None, None, None)
     loader.return_contents(response_mock, 'some-url', callback_mock, ctx)
     result = callback_mock.call_args[0][0]
     expect(result).to_be_instance_of(LoaderResult)
     expect(result.buffer).to_equal('body')
Пример #2
0
 def test_return_none_on_error(self):
     response_mock = ResponseMock(error='Error', code=599)
     callback_mock = mock.Mock()
     ctx = Context(None, None, None)
     loader.return_contents(response_mock, 'some-url', callback_mock, ctx)
     result = callback_mock.call_args[0][0]
     expect(result).to_be_instance_of(LoaderResult)
     expect(result.buffer).to_be_null()
     expect(result.successful).to_be_false()
Пример #3
0
 def test_return_upstream_error_on_body_empty(self):
     response_mock = ResponseMock(body='', code=200)
     callback_mock = mock.Mock()
     ctx = Context(None, None, None)
     loader.return_contents(response_mock, 'some-url', callback_mock, ctx)
     result = callback_mock.call_args[0][0]
     expect(result).to_be_instance_of(LoaderResult)
     expect(result.buffer).to_be_null()
     expect(result.successful).to_be_false()
     expect(result.error).to_equal(LoaderResult.ERROR_UPSTREAM)
Пример #4
0
 def topic(self, callback):
     mock = ResponseMock(body='body', code=200)
     ctx = Context(None, None, None)
     return loader.return_contents(mock, 'some-url', callback, ctx)
Пример #5
0
 def topic(self, callback):
     mock = ResponseMock(error='Error', code=599)
     ctx = Context(None, None, None)
     return loader.return_contents(mock, 'some-url', callback, ctx)