-
-
Save mephinet/7415a4641a65fbf0d51f0eae11ee21dc to your computer and use it in GitHub Desktop.
Reproducer for repeated metadata fetches by gspread-pandas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import pytest | |
from gspread_pandas import Spread | |
logging.basicConfig(level=logging.DEBUG) | |
SHEETID = "1sHawtVOpVoUonUg7O-vLweF9ate6da3HWC_VvDRp9W0" | |
SPREADURL = f"https://docs.google.com/spreadsheets/d/{SHEETID}" | |
def test_sheet_metadata_only_fetched_once(caplog): | |
caplog.set_level(logging.DEBUG, logger="urllib3.connectionpool") | |
gsc = Spread(spread=SPREADURL) | |
data1 = gsc.sheet_to_df(sheet="A") | |
data2 = gsc.sheet_to_df(sheet="B") | |
metadata_requests = [ | |
r | |
for r in caplog.records | |
if f"GET /v4/spreadsheets/{SHEETID}?includeGridData=false" in r.getMessage() | |
] | |
assert len(metadata_requests) == 1, metadata_requests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment