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()
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"
def test_main_calls_callback(self): from grabbags import grabbags run = Mock() grabbags.main(['somedir'], runner=run) assert run.called is True
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
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
def test_valid_cli_args(tmpdir, arguments): from grabbags import grabbags run = Mock() grabbags.main(arguments, runner=run) run.assert_called()
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()
from grabbags import grabbags if __name__ == '__main__': grabbags.main()