示例#1
0
def test_clean_bags_no_system_files(tmpdir):
    from grabbags import grabbags

    (tmpdir / "bag" / "text.txt").ensure()
    grabbags.main([tmpdir.strpath])
    grabbags.main([tmpdir.strpath, "--clean"])
    assert (tmpdir / "bag" / "data" / "text.txt").exists()
示例#2
0
    def test_single_shot_commands(self, cli_args):
        # Test commands that don't actually run bags but quit with return code
        # of zero before, such as help
        from grabbags import grabbags

        with pytest.raises(SystemExit) as e:
            grabbags.main(cli_args, runner=Mock())

        assert \
            e.value.args[0] == 0, \
            "if system exit is called with anything other than zero, the " \
            "grabbags did not close successfully"
示例#3
0
 def test_main_calls_callback(self):
     from grabbags import grabbags
     run = Mock()
     grabbags.main(['somedir'], runner=run)
     assert run.called is True
示例#4
0
 def test_invalid_fast_without_valid(self):
     from grabbags import grabbags
     with pytest.raises(SystemExit) as e:
         grabbags.main(['somedir', '--fast'])
     assert e.value.args[0] != 0
示例#5
0
 def test_invalid_processes(self):
     from grabbags import grabbags
     with pytest.raises(SystemExit) as e:
         grabbags.main(['somedir', '--processes=-1'])
     assert e.value.args[0] != 0
示例#6
0
def test_valid_cli_args(tmpdir, arguments):
    from grabbags import grabbags
    run = Mock()
    grabbags.main(arguments, runner=run)
    run.assert_called()
示例#7
0
def test_invalid_cli_args(arguments):
    from grabbags import grabbags
    with pytest.raises(SystemExit):
        run = Mock()
        grabbags.main(arguments, runner=run)
        run.assert_not_called()
示例#8
0
from grabbags import grabbags

if __name__ == '__main__':
    grabbags.main()