예제 #1
0
    def test_get_and_confirm_status_bad_result(self, _get):
        response = requests.Response()
        response.status_code = 500
        _get.return_value = response

        req = Requester('foo', 'bar', baseurl='http://dummy')
        with self.assertRaises(JenkinsAPIException) as ae:
            req.get_and_confirm_status(url='http://dummy',
                                       params={'param': 'value'})

        self.assertIsInstance(ae.exception, JenkinsAPIException)
예제 #2
0
    def test_get_and_confirm_status_bad_result(self, _get):
        response = requests.Response()
        response.status_code = 500
        _get.return_value = response

        req = Requester('foo', 'bar')
        with self.assertRaises(JenkinsAPIException) as ae:
            req.get_and_confirm_status(
                            url='http://dummy',
                            params={'param': 'value'})

        print ae.exception.message
        self.assertTrue(ae.exception.message=="Operation failed. url=None, headers=None, status=500, text=")
예제 #3
0
    def test_get_and_confirm_status_bad_result(self, _get):
        response = requests.Response()
        response.status_code = 500
        _get.return_value = response

        req = Requester('foo', 'bar', baseurl='http://dummy')
        with self.assertRaises(JenkinsAPIException) as ae:
            req.get_and_confirm_status(
                url='http://dummy',
                params={'param': 'value'}
            )

        self.assertIsInstance(ae.exception, JenkinsAPIException)
예제 #4
0
    def test_get_and_confirm_status_bad_result(self, _get):
        response = requests.Response()
        response.status_code = 500
        _get.return_value = response

        req = Requester('foo', 'bar')
        with self.assertRaises(JenkinsAPIException) as ae:
            req.get_and_confirm_status(url='http://dummy',
                                       params={'param': 'value'})

        print ae.exception.message
        self.assertTrue(
            ae.exception.message ==
            "Operation failed. url=None, headers=None, status=500, text=")
예제 #5
0
def test_get_and_confirm_status_bad_result(monkeypatch):
    class FakeResponse(object):
        def __init__(self, *args, **kwargs):  # pylint: disable=unused-argument
            self.status_code = 500
            self.url = 'http://dummy'
            self.text = 'something'

    def fake_get(*args, **kwargs):  # pylint: disable=unused-argument
        return FakeResponse()

    monkeypatch.setattr(requests, 'get', fake_get)

    req = Requester('foo', 'bar', baseurl='http://dummy')
    with pytest.raises(JenkinsAPIException):
        req.get_and_confirm_status(url='http://dummy',
                                   params={'param': 'value'})
예제 #6
0
 def test_get_and_confirm_status(self, _get):
     response = requests.Response()
     response.status_code = 200
     _get.return_value = response
     req = Requester('foo', 'bar')
     ret = req.get_and_confirm_status(url='http://dummy',
                                      params={'param': 'value'})
     self.assertTrue(isinstance(ret, requests.Response))
예제 #7
0
 def test_get_and_confirm_status(self, _get):
     response = requests.Response()
     response.status_code = 200
     _get.return_value = response
     req = Requester('foo', 'bar')
     ret = req.get_and_confirm_status(
                     url='http://dummy',
                     params={'param': 'value'})
     self.assertTrue(isinstance(ret, requests.Response))
예제 #8
0
def test_get_and_confirm_status_bad_result(monkeypatch):
    class FakeResponse(object):
        def __init__(self, *args, **kwargs):  # pylint: disable=unused-argument
            self.status_code = 500
            self.url = 'http://dummy'
            self.text = 'something'

    def fake_get(*args, **kwargs):  # pylint: disable=unused-argument
        return FakeResponse()

    monkeypatch.setattr(requests, 'get', fake_get)

    req = Requester('foo', 'bar', baseurl='http://dummy')
    with pytest.raises(JenkinsAPIException):
        req.get_and_confirm_status(
            url='http://dummy',
            params={'param': 'value'}
        )
예제 #9
0
def test_get_and_confirm_status(monkeypatch):
    class FakeResponse(requests.Response):
        def __init__(self, *args, **kwargs):  # pylint: disable=unused-argument
            self.status_code = 200

    def fake_get(*args, **kwargs):  # pylint: disable=unused-argument
        return FakeResponse()

    monkeypatch.setattr(requests, 'get', fake_get)

    req = Requester('foo', 'bar')
    ret = req.get_and_confirm_status(url='http://dummy',
                                     params={'param': 'value'})
    assert isinstance(ret, requests.Response)
예제 #10
0
def test_get_and_confirm_status(monkeypatch):
    class FakeResponse(requests.Response):
        def __init__(self, *args, **kwargs):  # pylint: disable=unused-argument
            self.status_code = 200

    def fake_get(*args, **kwargs):  # pylint: disable=unused-argument
        return FakeResponse()

    monkeypatch.setattr(requests, 'get', fake_get)

    req = Requester('foo', 'bar')
    ret = req.get_and_confirm_status(
        url='http://dummy',
        params={'param': 'value'}
    )
    assert isinstance(ret, requests.Response)