コード例 #1
0
ファイル: test_cli.py プロジェクト: RCOSDP/rdmclient
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]
コード例 #2
0
ファイル: test_cli.py プロジェクト: RCOSDP/rdmclient
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'
コード例 #3
0
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