1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
import pathlib
import shutil
try:
import cPickle as pickle # type: ignore
except Exception:
import pickle
import googleapiclient.discovery
TEST_DATA_DIR = pathlib.Path(__file__).parent / 'data'
def test_legacy_certs(tmpdir, gcali_patches, patched_google_reauth):
tmpdir = pathlib.Path(tmpdir)
oauth_filepath = tmpdir / 'oauth'
shutil.copy(TEST_DATA_DIR / 'legacy_oauth_creds.json', oauth_filepath)
gcal = gcali_patches.GCalI(data_path=tmpdir, refresh_cache=False)
assert isinstance(
gcal.get_cal_service(), googleapiclient.discovery.Resource
)
with open(oauth_filepath, 'rb') as gcalcli_oauth:
try:
pickle.load(gcalcli_oauth)
except Exception as e:
raise AssertionError(
f"Couldn't load oauth file as updated pickle format: {e}"
)
|