示例#1
0
def test_credentials_with_cache(cache_path, token, section):
    write_token_to_cache(section, (token['access_token'], token['expires_in']),
                         cache_path)
    credentials = Credentials(*read_from_environ(),
                              cached_profile=section,
                              cache_path=cache_path)
    assert credentials._token == (token['access_token'], token['expires_in'])
    assert credentials.cached_profile == section
示例#2
0
def test_read_from_file_without_cache(credentials_path, section, token,
                                      cache_path):
    write_token_to_cache(section, (token['access_token'], token['expires_in']),
                         cache_path)
    args = read_from_file(str(credentials_path), section)

    credentials = Credentials(*args, cache_path=cache_path)
    assert credentials.cached_profile is None
    assert credentials._token == NULL_TOKEN
示例#3
0
def test_read_from_file_with_cache(credentials_path, section, token,
                                   cache_path):
    write_token_to_cache(section, (token['access_token'], token['expires_in']),
                         cache_path)
    credentials_path.write_text(credentials_path.read_text() +
                                '\nuse_cache = true')
    args = read_from_file(str(credentials_path), section)

    credentials = Credentials(*args, cache_path=cache_path)
    assert credentials.cached_profile == section
    assert credentials._token == (token['access_token'], token['expires_in'])
示例#4
0
def test_write_token_to_cache(cache_path, token, section):
    write_token_to_cache(section, (token['access_token'], token['expires_in']),
                         cache_path)
    cache = json.loads(cache_path.read_text())
    assert token == cache[section]