예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
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')
예제 #4
0
 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
예제 #5
0
 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()
예제 #6
0
 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
예제 #7
0
 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
예제 #8
0
 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