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)
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)