File: test_auth.py

package info (click to toggle)
gcalcli 4.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,376 kB
  • sloc: python: 4,135; makefile: 10; sh: 7
file content (28 lines) | stat: -rw-r--r-- 849 bytes parent folder | download
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}"
            )