def test_parse_args_one_arg(self, capsys): with pytest.raises(SystemExit) as excinfo: parse_args(['foo']) assert excinfo.value.code == 2 out, err = capsys.readouterr() assert ( 'too few arguments' in err or 'the following arguments are required' in err ) assert out == ''
def test_parse_args_version(self, capsys): with pytest.raises(SystemExit) as excinfo: parse_args(['-V']) assert excinfo.value.code == 0 expected = "s3sfe v%s <%s>\n" % ( VERSION, PROJECT_URL ) out, err = capsys.readouterr() if (sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 4)): assert out == '' assert err == expected else: assert out == expected assert err == ''
def test_parse_args_basic(self): res = parse_args(['-f', 'kf', 'bktname', '/foo/bar']) assert res.BUCKET_NAME == 'bktname' assert res.FILELIST_PATH == '/foo/bar' assert res.verbose == 0 assert res.dry_run is False assert res.prefix is None assert res.summary is False assert res.key_file == 'kf' assert res.exclude_file is None
def test_parse_args_summary(self): res = parse_args(['-f', 'kf', '--summary', 'bktname', '/foo/bar']) assert res.summary is True
def test_parse_args_prefix(self): res = parse_args( ['-f', 'kf', '--s3-prefix=foo/bar', 'bktname', '/foo/bar'] ) assert res.prefix == 'foo/bar'
def test_parse_args_exclude(self): res = parse_args(['-f', 'kf', '-e', '/exc/f', 'bktname', '/foo/bar']) assert res.exclude_file == '/exc/f'
def test_parse_args_dry_run(self): res = parse_args(['-f', 'kf', '-d', 'bktname', '/foo/bar']) assert res.dry_run is True
def test_parse_args_verbose2(self): res = parse_args(['-f', 'kf', '-vv', 'bktname', '/foo/bar']) assert res.verbose == 2
def test_parse_args_no_key_file(self): with pytest.raises(RuntimeError): parse_args(['-v', 'bktname', '/foo/bar'])