コード例 #1
0
ファイル: test_core.py プロジェクト: lcarva/osbs-client
 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))
コード例 #2
0
ファイル: test_core.py プロジェクト: jarodwilson/osbs-client
    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
コード例 #3
0
    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
コード例 #4
0
ファイル: test_core.py プロジェクト: jarodwilson/osbs-client
    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
コード例 #5
0
ファイル: test_core.py プロジェクト: lcarva/osbs-client
    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
コード例 #6
0
 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))