Exemplo n.º 1
0
def fake_creds(config_dir='.jovian',
               creds_filename='credentials.json',
               extra=None):
    with temp_directory() as dir:
        _d, _f = credentials.CONFIG_DIR, credentials.CREDS_FNAME
        credentials.CONFIG_DIR = os.path.join(dir, config_dir)
        credentials.CREDS_FNAME = creds_filename
        creds = {
            "GUEST_KEY": "b6538d4dfde04fcf993463a828a9cec6",
            "API_URL": "https://api-staging.jovian.ai",
            "WEBAPP_URL": "https://staging.jovian.ai/",
            "ORG_ID": "staging",
            "API_KEY": "fake_api_key",
        }

        if extra and isinstance(extra, dict):
            creds.update(extra)

        write_creds(creds)
        try:
            yield dir
        finally:
            purge_config()
        credentials.CONFIG_DIR = _d
        credentials.CREDS_FNAME = _f
Exemplo n.º 2
0
def fake_creds(config_dir, creds_filename):
    _d, _f = credentials.CONFIG_DIR, credentials.CREDS_FNAME
    credentials.CONFIG_DIR = 'jovian/tests/resources/creds/' + config_dir
    credentials.CREDS_FNAME = creds_filename
    creds = {
        "GUEST_KEY": "b6538d4dfde04fcf993463a828a9cec6",
        "API_URL": "https://api-staging.jovian.ai",
        "WEBAPP_URL": "https://staging.jovian.ml/",
        "ORG_ID": "staging",
        "API_KEY": "fake_api_key"
    }
    write_creds(creds)
    try:
        yield
    finally:
        purge_config()
    credentials.CONFIG_DIR = _d
    credentials.CREDS_FNAME = _f
Exemplo n.º 3
0
def test_purge_config():
    with fake_creds():
        os.makedirs(credentials.CONFIG_DIR, exist_ok=True)
        assert config_exists() == True
        purge_config()
        assert config_exists() == False
Exemplo n.º 4
0
def test_config_exits_false():
    with fake_creds():
        purge_config()
        assert config_exists() == False
Exemplo n.º 5
0
def test_config_exits_false():
    with fake_creds('.jovian-does-not-exist', 'credentials.json'):
        purge_config()
        assert config_exists() == False