Exemplo n.º 1
0
 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 == ''
Exemplo n.º 2
0
 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 == ''
Exemplo n.º 3
0
 def test_parse_args_basic(self):
     res = parse_args(['-f', 'kf', 'bktname', '/foo/bar', '/baz'])
     assert res.dry_run is False
     assert res.verbose == 0
     assert res.prefix is None
     assert res.key_file == 'kf'
     assert res.FILELIST_PATH is None
     assert res.BUCKET_NAME == 'bktname'
     assert res.LOCAL_PREFIX == '/foo/bar'
     assert res.PATH == ['/baz']
Exemplo n.º 4
0
 def test_parse_args_multi_path(self):
     res = parse_args(
         ['-f', 'kf', 'bktname', '/foo/bar', '/p1', '/p2', '/p3'])
     assert res.FILELIST_PATH is None
     assert res.PATH == ['/p1', '/p2', '/p3']
Exemplo n.º 5
0
 def test_parse_args_filelist(self):
     res = parse_args(
         ['-f', 'kf', '-l', '/filelist', 'bktname', '/foo/bar'])
     assert res.FILELIST_PATH == '/filelist'
     assert res.PATH == []
Exemplo n.º 6
0
 def test_parse_args_prefix(self):
     res = parse_args([
         '-f', 'kf', '--s3-prefix=foo/bar', 'bktname', '/foo/bar', '/path'
     ])
     assert res.prefix == 'foo/bar'
Exemplo n.º 7
0
 def test_parse_args_verbose2(self):
     res = parse_args(['-f', 'kf', '-vv', 'bktname', '/foo/bar', '/path'])
     assert res.verbose == 2
Exemplo n.º 8
0
 def test_parse_args_dry_run(self):
     res = parse_args(['-f', 'kf', '-d', 'bktname', '/foo/bar', '/path'])
     assert res.dry_run is True
Exemplo n.º 9
0
 def test_parse_args_no_key_file(self):
     with pytest.raises(RuntimeError):
         parse_args(['-v', 'bktname', '/foo/bar'])
Exemplo n.º 10
0
 def test_parse_args_path_and_filelist(self):
     with pytest.raises(RuntimeError):
         parse_args([
             '-f', 'kf', '-l', '/filelist', 'bktname', '/foo/bar', '/path'
         ])
Exemplo n.º 11
0
 def test_parse_args_no_path_no_filelist(self):
     with pytest.raises(RuntimeError):
         parse_args(['-f', 'kf', 'bktname', '/foo/bar'])