def test_initialize(self, mocker, tmpdir): tester = cmdline.CLI() m1 = mocker.patch('pyentrez.main.cmdline.GetParser.get_parser', return_value=MockedParser.set_1(tmpdir)) tester.initialize() assert tester.args.get('Home') == str(tmpdir) assert m1.called
def test_run_pyentrez_notui(self, mocker): tester = cmdline.CLI() tester.args = test_args[1] tester.args['verbose'] = None tester.args['output'] = None m0 = mocker.patch('pyentrez.configure_logger') m1 = mocker.patch('pyentrez.main.cmdline.CLI.starttui') m2 = mocker.patch('pyentrez.main.cmdline.CLI.notui') tester.run_pyentrez() assert m0.called assert not m1.called assert m2.called
def main(argv=None): """Execute the main application. Creates instance of cmdline, runs it, and exits the application. Args: argv(List[str]): Arguments to be passed into the application for parsing. """ if sys.version_info > (3, 8): cmd = cmdline.CLI() cmd.execute() cmd.clean_exit() else: raise Exception('Script needs to be run with Python 3.8')
def test_run_pyentrez_init(self, mocker): tester = cmdline.CLI() tester.args = test_args[2] m1 = mocker.patch('pyentrez.main.user_cred.first_run') tester.run_pyentrez() assert m1.called
def test_run_pyentrez_version(self): tester = cmdline.CLI() tester.args = test_args[0] tester.args['version'] = True with pytest.raises(SystemExit): tester.run_pyentrez()
def test_execute_earlyquit(self, mocker): tester = cmdline.CLI() m1 = mocker.patch('pyentrez.main.cmdline.CLI._run', side_effect=exceptions.EarlyQuit("Raised")) tester.execute() assert tester.catastrophic_failure is True
def test_execute_keyboardinterrupt(self, mocker): tester = cmdline.CLI() m1 = mocker.patch('pyentrez.main.cmdline.CLI._run', side_effect=KeyboardInterrupt) tester.execute() assert tester.catastrophic_failure is True
def test_mocker(self, mocker): tester = cmdline.CLI() m1 = mocker.patch('pyentrez.main.cmdline.CLI.execute') tester.execute() assert m1.called assert tester.catastrophic_failure is False