def test_stream_logs_error(self, openshift): ex = OsbsNetworkException('/', '', pycurl.E_COULDNT_RESOLVE_HOST) (flexmock(openshift) .should_receive('_get') .and_raise(ex)) with pytest.raises(OsbsNetworkException): list(openshift.stream_logs(TEST_BUILD))
def test_stream_logs_utf8(self, openshift): # noqa response = flexmock(status_code=httplib.OK) (response.should_receive('iter_lines').and_return([ u"{'stream': 'Uňícode íš hářd\n'}".encode('utf-8') ]).and_raise(StopIteration)) (flexmock(openshift).should_receive('_get').and_return(response)) logs = openshift.stream_logs(TEST_BUILD) assert len([log for log in logs]) == 1
def test_stream_logs(self, openshift): ex = OsbsNetworkException('/', '', pycurl.FOLLOWLOCATION) response = flexmock(status_code=httplib.OK) (response.should_receive('iter_lines').and_return( ["{'stream': 'foo\n'}"]).and_raise(StopIteration)) (flexmock(openshift).should_receive('_get') # First: timeout in response after 100s .and_raise(ex) # Next: return a real response .and_return(response)) (flexmock(time).should_receive('time').and_return(0).and_return(100)) logs = openshift.stream_logs(TEST_BUILD) assert len([log for log in logs]) == 1
def test_stream_logs_bad_initial_connection(self, openshift, exc): response = flexmock(status_code=httplib.OK) (response.should_receive('iter_lines').and_return( [b"{'stream': 'foo\n'}"]).and_raise(StopIteration)) wrapped_exc = OsbsNetworkException('http://spam.com', str(exc), status_code=None, cause=exc) (flexmock(openshift).should_receive('_get') # First: simulate initial connection problem .and_raise(wrapped_exc) # Next: return a real response .and_return(response)) (flexmock(time).should_receive('time').and_return(0).and_return(100)) logs = openshift.stream_logs(TEST_BUILD) assert len([log for log in logs]) == 1
def test_stream_logs(self, openshift): ex = OsbsNetworkException('/', '', pycurl.FOLLOWLOCATION) response = flexmock(status_code=httplib.OK) (response .should_receive('iter_lines') .and_return(["{'stream': 'foo\n'}"]) .and_raise(StopIteration)) (flexmock(openshift) .should_receive('_get') # First: timeout in response after 100s .and_raise(ex) # Next: return a real response .and_return(response)) (flexmock(time) .should_receive('time') .and_return(0) .and_return(100)) logs = openshift.stream_logs(TEST_BUILD) assert len([log for log in logs]) == 1
def test_stream_logs_error(self, openshift): ex = OsbsNetworkException('/', '', pycurl.E_COULDNT_RESOLVE_HOST) (flexmock(openshift).should_receive('_get').and_raise(ex)) with pytest.raises(OsbsNetworkException): list(openshift.stream_logs(TEST_BUILD))