Beispiel #1
0
def test_config_project():
    # No project in args or the config, should sys.exit(1)
    args = MockArgs(project=None)

    def simple_config(key):
        return {}

    with patch('osfclient.cli.config_from_env', side_effect=simple_config):
        with pytest.raises(SystemExit) as e:
            cli._setup_osf(args)

    expected = ('specify a project ID via the command line, configuration '
                'file or environment variable')
    assert expected in e.value.args[0]
Beispiel #2
0
def test_password_prompt():
    # No password in config should trigger the password prompt
    # when an username is specified
    args = MockArgs(project='test', username='******')
    with patch('getpass.getpass') as getpass:
        getpass.return_value = 'test_password'
        osf = cli._setup_osf(args)
        assert osf.password == 'test_password'
def checkfile(args):
    storage, remote_path = utils.split_storage(args.remote)
    osf = cli._setup_osf(args)
    project = osf.project(args.project)
    store = project.storage(storage)
    exists = False

    for f in store.files:
        if utils.norm_remote_path(f.path) == remote_path:
            print("%s exists!" % remote_path)
            exists = True
            break
    if not exists:
        print('%s does not exist!' % remote_path)
    return exists