Пример #1
0
 def test_post_xml_and_confirm_status_empty_xml(self, _post):
     _post.return_value = mock.Mock()
     req = Requester('foo', 'bar')
     with self.assertRaises(AssertionError) as ae:
         req.post_xml_and_confirm_status(url='http://dummy',
                                         params={'param': 'value'},
                                         data=None)
Пример #2
0
 def test_post_xml_and_confirm_status_empty_xml(self, _post):
     _post.return_value = mock.Mock()
     req = Requester('foo', 'bar')
     with self.assertRaises(AssertionError) as ae:
         req.post_xml_and_confirm_status(
             url='http://dummy',
             params={'param': 'value'},
             data=None
         )
Пример #3
0
    def test_post_xml_and_confirm_status_empty_xml(self, _post):
        _post.return_value = 'SUCCESS'
        req = Requester('foo', 'bar')
        with self.assertRaises(AssertionError) as ae:
            req.post_xml_and_confirm_status(
                            url='http://dummy',
                            params={'param': 'value'},
                            data=None)

        self.assertTrue(ae.exception.message=="Unexpected type of parameter 'data': <type 'NoneType'>. Expected (str, dict)")
Пример #4
0
def test_post_xml_empty_xml(monkeypatch):
    def fake_post(*args, **kwargs):  # pylint: disable=unused-argument
        return 'SUCCESS'

    monkeypatch.setattr(requests, 'post', fake_post)

    req = Requester('foo', 'bar')
    with pytest.raises(AssertionError):
        req.post_xml_and_confirm_status(url='http://dummy',
                                        params={'param': 'value'},
                                        data=None)
    def test_post_xml_and_confirm_status_empty_xml(self, _post):
        _post.return_value = 'SUCCESS'
        req = Requester('foo', 'bar')
        with self.assertRaises(AssertionError) as ae:
            req.post_xml_and_confirm_status(
                url='http://dummy',
                params={'param': 'value'},
                data=None
            )

        self.assertTrue(str(ae.exception) == "Unexpected type of parameter 'data': %s. Expected (str, dict)" % type(None))
Пример #6
0
def test_post_xml_empty_xml(monkeypatch):
    def fake_post(*args, **kwargs):  # pylint: disable=unused-argument
        return 'SUCCESS'

    monkeypatch.setattr(requests, 'post', fake_post)

    req = Requester('foo', 'bar')
    with pytest.raises(AssertionError):
        req.post_xml_and_confirm_status(
            url='http://dummy',
            params={'param': 'value'},
            data=None
        )
Пример #7
0
 def test_post_xml_and_confirm_status_some_xml(self, _post):
     response = requests.Response()
     response.status_code = 200
     _post.return_value = response
     req = Requester('foo', 'bar')
     ret = req.post_xml_and_confirm_status(url='http://dummy',
                                           params={'param': 'value'},
                                           data='<xml/>')
     self.assertTrue(isinstance(ret, requests.Response))
Пример #8
0
 def test_post_xml_and_confirm_status_some_xml(self, _post):
     response = requests.Response()
     response.status_code = 200
     _post.return_value = response
     req = Requester('foo', 'bar')
     ret = req.post_xml_and_confirm_status(
                     url='http://dummy',
                     params={'param': 'value'},
                     data='<xml/>')
     self.assertTrue(isinstance(ret, requests.Response))
Пример #9
0
def test_post_xml_and_confirm_status_some_xml(monkeypatch):
    class FakeResponse(requests.Response):
        def __init__(self, *args, **kwargs):  # pylint: disable=unused-argument
            self.status_code = 200

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

    monkeypatch.setattr(requests, 'post', fake_post)

    req = Requester('foo', 'bar')
    ret = req.post_xml_and_confirm_status(url='http://dummy',
                                          params={'param': 'value'},
                                          data='<xml/>')
    assert isinstance(ret, requests.Response)
Пример #10
0
def test_post_xml_and_confirm_status_some_xml(monkeypatch):
    class FakeResponse(requests.Response):
        def __init__(self, *args, **kwargs):  # pylint: disable=unused-argument
            self.status_code = 200

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

    monkeypatch.setattr(requests, 'post', fake_post)

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