def test_restclient_corrects_missing_slashes_in_urls(self): client = ByteRESTClient(endpoint="http://henk.nl/api") client.headers = {} client.get("hypernode/") self.mock_get.assert_called_once_with( "http://henk.nl/api/hypernode/", data='{}', headers={}, allow_redirects=False )
def test_restclient_passes_extra_parameters_to_requests(self): client = ByteRESTClient(endpoint='http://henk.nl/api') client.headers = {} client.get('hypernode', params={"q": "mynode"}) self.mock_get.assert_called_once_with( "http://henk.nl/api/hypernode", headers={}, params={"q": "mynode"}, data='{}', allow_redirects=False )
def test_restclient_has_get_shortcut(self): client = ByteRESTClient() client.request = mock.MagicMock(return_value=42) ret = client.get("/get/") client.request.assert_called_once_with('get', "/get/") self.assertEqual(ret, 42) # returned client.request return value