Exemple #1
0
    def test_get_fail(self):
        session = Mock()
        session.get = Mock(side_effect=RequestException)
        http_client = RequestsHttpClient(session)

        response = http_client.get("an url", {"some": "params"})

        session.get.assert_called_with("an url", params={"some": "params"})
        self.assertEquals(False, response)
Exemple #2
0
    def test_get_ok(self):
        session = Mock()
        resp = Mock()
        resp.text = "some text"
        session.get.return_value = resp
        http_client = RequestsHttpClient(session)

        response = http_client.get("an url", {"some": "params"})

        session.get.assert_called_with("an url", params={"some": "params"})
        self.assertEquals("some text", response)