Exemple #1
0
 def test_raise_http_request(self, urlopen):
     error = http.HTTPError('http://example.com/', 404, 'Not Found', None,
                            None)
     error.read = lambda: b'o'
     urlopen.side_effect = error
     resp, content = OAuthRemoteApp.http_request('http://example.com')
     assert resp.code == 404
     assert b'o' in content
Exemple #2
0
    def test_http_request(self, urlopen):
        urlopen.return_value = Response(b'{"foo": "bar"}',
                                        headers={'status-code': 200})

        resp, content = OAuthRemoteApp.http_request('http://example.com')
        assert resp.code == 200
        assert b'foo' in content

        resp, content = OAuthRemoteApp.http_request(
            'http://example.com/', method='GET', data={'wd': 'flask-oauthlib'})
        assert resp.code == 200
        assert b'foo' in content

        resp, content = OAuthRemoteApp.http_request(
            'http://example.com/', data={'wd': 'flask-oauthlib'})
        assert resp.code == 200
        assert b'foo' in content
 def test_raise_http_request(self, urlopen):
     error = http.HTTPError(
         'http://example.com/', 404, 'Not Found', None, None
     )
     error.read = lambda: b'o'
     urlopen.side_effect = error
     resp, content = OAuthRemoteApp.http_request('http://example.com')
     assert resp.code == 404
     assert b'o' in content
    def test_http_request(self, urlopen):
        urlopen.return_value = Response(
            b'{"foo": "bar"}', headers={'status-code': 200}
        )

        resp, content = OAuthRemoteApp.http_request('http://example.com')
        assert resp.code == 200
        assert b'foo' in content

        resp, content = OAuthRemoteApp.http_request(
            'http://example.com/',
            method='GET',
            data={'wd': 'flask-oauthlib'}
        )
        assert resp.code == 200
        assert b'foo' in content

        resp, content = OAuthRemoteApp.http_request(
            'http://example.com/',
            data={'wd': 'flask-oauthlib'}
        )
        assert resp.code == 200
        assert b'foo' in content
    def test_raise_http_request(self, urlopen):
        error = http.HTTPError('http://example.com/', 404, 'Not Found', None,
                               None)
        error.read = lambda: b'o'

        class _Fake(object):
            def close(self):
                return 0

        class _Faker(object):
            _closer = _Fake()

        error.file = _Faker()

        urlopen.side_effect = error
        resp, content = OAuthRemoteApp.http_request('http://example.com')
        assert resp.code == 404
        assert b'o' in content
    def test_raise_http_request(self, urlopen):
        error = http.HTTPError(
            'http://example.com/', 404, 'Not Found', None, None
        )
        error.read = lambda: b'o'

        class _Fake(object):
            def close(self):
                return 0

        class _Faker(object):
            _closer = _Fake()

        error.file = _Faker()

        urlopen.side_effect = error
        resp, content = OAuthRemoteApp.http_request('http://example.com')
        assert resp.code == 404
        assert b'o' in content