def test_ok(self): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'clean', '--debug', '--dir', __file__.rsplit('/', 2)[0] ]) pass
def test_ok(self): parser.parse(argparse.ArgumentParser(), argv=['command', 'compile', '--debug', '--dir', __file__.rsplit('/', 2)[ 0]]) pass
def test_optimize(self): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'compile', '-OO', '--debug', '--dir', __file__.rsplit('/', 2)[0] ]) pass
def test_only_upload_key(self): """ ..note:: for safety reason, we only use github token test github work progress. so make sure your token is valid. ..todo:: this feature doesn't test yet. :return: """ with mock.patch(mock_input, side_effect=["\n", "\n"]): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'deploy', '--debug', '--env', 'beta', '--with-deploy-key', '--fresh-new', '--skip-requirements', '--skip-compile-templates', '--skip-upload-resources', '--dir', __file__.rsplit('/', 2)[0] ]) pass pass
def test_only_static(self): """ ..note:: for safety reason, we only use github token test github work progress. so make sure your token is valid. ..todo:: this feature doesn't test yet. :return: """ # os.chdir(os.path.join(__file__.rsplit('/', 3)[0], 'dream')) parser.parse(argparse.ArgumentParser(), argv=['command', 'deploy', '--debug', '--env', 'beta', '--skip-source-code', '--skip-requirements', '--skip-compile-templates', '--dir', __file__.rsplit('/', 2)[ 0]]) pass
def test_only_pyenv_local_mac(self): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'install', '--debug', '--skip-pkg', '--skip-node', '--env', 'dev', '--dir', __file__.rsplit('/', 2)[0] ])
def test_only_upload_key(self): """ ..note:: for safety reason, we only use github token test github work progress. so make sure your token is valid. ..todo:: this feature doesn't test yet. :return: """ with mock.patch(mock_input, side_effect=["\n", "\n"]): parser.parse(argparse.ArgumentParser(), argv=['command', 'deploy', '--debug', '--env', 'beta', '--with-deploy-key', '--fresh-new', '--skip-requirements', '--skip-compile-templates', '--skip-upload-resources', '--dir', __file__.rsplit('/', 2)[ 0]]) pass pass
def test_on_centos(self): parser.parse(argparse.ArgumentParser(), argv=['command', 'config', '--debug', '--env', 'beta', '--dir', __file__.rsplit('/', 2)[ 0]]) pass
def test_list(self): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'hardline', '--list', '--dir', __file__.rsplit('/', 2)[0] ]) pass
def test_on_centos(self): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'config', '--debug', '--env', 'beta', '--dir', __file__.rsplit('/', 2)[0] ]) pass
def test_only_enable(self): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'config', '--debug', '--env', 'beta', '--skip-upload', '--dir', __file__.rsplit('/', 2)[0] ]) pass
def test_only_node_remote_mac(self): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'install', '--debug', '--skip-pkg', '--skip-pyenv', '--env', 'beta2', '--dir', __file__.rsplit('/', 2)[0] ]) pass
def test_ok(self): dp = tempfile.TemporaryDirectory() parser.parse(argparse.ArgumentParser(), argv=['command', 'create', '9nix00/cliez-kickstart', '--dir', dp.name, '--debug']) with mock.patch(mock_input, side_effect=['yes', 'pkg_demo', "\n", "\n"]): parser.parse(argparse.ArgumentParser(), argv=['command', 'init', '--dir', dp.name, '--debug']) pass
def test_workflow(self): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'hardline', 'normal', '--preview', '--dir', __file__.rsplit('/', 2)[0] ]) pass
def test_mini(self): parser.parse(argparse.ArgumentParser(), argv=['command', 'mini', os.path.join(os.path.dirname(__file__), 'resources', 'mini_input'), os.path.join(os.path.dirname(__file__), 'resources', 'mini_output') ]) pass
def test_only_restart(self): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'config', '--debug', '--env', 'beta', '--skip-enable-services', '--skip-upload', '--restart', 'nginx', 'redis', '--dir', __file__.rsplit('/', 2)[0] ]) pass
def test_invalid_env(self): with self.assertRaises(OSError): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'install', '--debug', '--env', 'invalid-env', '--dir', __file__.rsplit('/', 2)[0] ]) pass
def test_only_pyenv_centos(self): parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'install', '--debug', '--skip-pkg', '--skip-node', '--skip-user', '--env', 'beta', '--dir', __file__.rsplit('/', 2)[0] ]) pass
def test_list(self): parser.parse(argparse.ArgumentParser(), argv=['command', 'hardline', '--list', '--dir', __file__.rsplit('/', 2)[ 0]]) pass
def test_only_enable(self): parser.parse(argparse.ArgumentParser(), argv=['command', 'config', '--debug', '--env', 'beta', '--skip-upload', '--dir', __file__.rsplit('/', 2)[ 0]]) pass
def test_workflow(self): parser.parse(argparse.ArgumentParser(), argv=['command', 'hardline', 'normal', '--preview', '--dir', __file__.rsplit('/', 2)[ 0]]) pass
def test_no_confirm(self): """ :return: """ with tempfile.TemporaryDirectory() as dp: with mock.patch(mock_input, side_effect=['pkg_demo', "\n", "\n"]): parser.parse(argparse.ArgumentParser(), argv=['command', 'init', '--yes', '--dir', dp]) pass
def test_missing(self): """ missing argument :return: """ with self.assertRaises(SystemExit): parser.parse(argparse.ArgumentParser(), argv=['command', 'create']) pass
def test_skip_builtin(self): """ custom variable :return: """ with tempfile.TemporaryDirectory() as dp: parser.parse(argparse.ArgumentParser(), argv=['command', 'create', '9nix00/cliez-kickstart', '--dir', dp, '--debug']) parser.parse(argparse.ArgumentParser(), argv=['command', 'init', '--dir', dp, '--debug', '-s', 'keywords:a-keyword', '--skip-builtin', '--yes']) pass
def test_github_mode(self): """ github mode :return: """ with tempfile.TemporaryDirectory() as dp: parser.parse(argparse.ArgumentParser(), argv=['command', 'create', '9nix00/cliez-kickstart', '--dir', dp, # you must be specify `--dir` option in testcase '--debug']) pass
def test_invalid_env(self): with self.assertRaises(OSError): parser.parse(argparse.ArgumentParser(), argv=['command', 'config', '--debug', '--env', 'invalid-env', '--dir', __file__.rsplit('/', 2)[ 0]]) pass
def test_mini_extension_dry_run(self): parser.parse(argparse.ArgumentParser(), argv=['command', 'mini', os.path.join(os.path.dirname(__file__), 'resources', 'mini_input'), os.path.join(os.path.dirname(__file__), 'resources', 'mini_output'), '--dry-run', '--extension', '.py', '.txt' ]) pass
def test_only_restart(self): parser.parse(argparse.ArgumentParser(), argv=['command', 'config', '--debug', '--env', 'beta', '--skip-enable-services', '--skip-upload', '--restart', 'nginx', 'redis', '--dir', __file__.rsplit('/', 2)[ 0]]) pass
def test_with_variables(self): """ custom variable :return: """ with tempfile.TemporaryDirectory() as dp: parser.parse(argparse.ArgumentParser(), argv=['command', 'create', '9nix00/cliez-kickstart', '--dir', dp, '--debug']) with mock.patch(mock_input, side_effect=['yes', 'pkg_demo', "\n", "\n"]): parser.parse(argparse.ArgumentParser(), argv=['command', 'init', '--dir', dp, '--debug', '-s', 'keywords:a-keyword']) pass
def main(): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, epilog=conf.EPILOG, ) for v in conf.GENERAL_ARGUMENTS: parser.add_argument(*v[0], **v[1]) parser.add_argument('--version', '-V', action='version', version='%(prog)s v{}'.format(version)) parse(parser) pass
def test_mini_extension_prepend(self): parser.parse(argparse.ArgumentParser(), argv=['command', 'mini', os.path.join(os.path.dirname(__file__), 'resources', 'mini_input'), os.path.join(os.path.dirname(__file__), 'resources', 'mini_output'), '--extension', '.py', '.txt', '--debug', '--prepend', os.path.join(os.path.dirname(__file__), 'resources', 'mini_input', 'COPYRIGHT'), ]) pass
def test_in_dange_root(self): """ 缺失参数 :return: """ with self.assertRaises(SystemExit): with mock.patch(mock_input, side_effect=['yes', 'pkg_demo', "\n", "\n"]): parser.parse(argparse.ArgumentParser(), argv=['command', 'init', '--dir', '/']) os.chdir(os.path.expanduser('~')) with self.assertRaises(SystemExit): with mock.patch(mock_input, side_effect=['yes', 'pkg_demo', "\n", "\n"]): parser.parse(argparse.ArgumentParser(), argv=['command', 'init', '--dir', '/']) pass
def main(): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, epilog=conf.EPILOG, ) for v in conf.GENERAL_ARGUMENTS: parser.add_argument(*v[0], **v[1]) parser.add_argument('--version','-V', action='version', version='%(prog)s v{}'.format(version)) # do nothing when no argument applied # parse(parser) parse(parser) pass
def test_only_static(self): """ ..note:: for safety reason, we only use github token test github work progress. so make sure your token is valid. ..todo:: this feature doesn't test yet. :return: """ # os.chdir(os.path.join(__file__.rsplit('/', 3)[0], 'dream')) parser.parse(argparse.ArgumentParser(), argv=[ 'command', 'deploy', '--debug', '--env', 'beta', '--skip-source-code', '--skip-requirements', '--skip-compile-templates', '--dir', __file__.rsplit('/', 2)[0] ]) pass
def test_allow_show_version(self): with self.assertRaises(SystemExit): # "will call parser.exit" parser.parse(self.parser, argv=['command', '--version']) pass
def test_active_show_invalid(self): with self.assertRaises(SystemExit): # "unknow params" result = parser.parse(self.parser, argv=['command', '--port']) self.assertEqual(result, version) pass
def test_ignore_set_root(self): with self.assertRaises(SystemExit): conf.COMPONENT_ROOT = None parser.parse(self.parser, argv=['anything']) pass pass
def test_no_args_func(self): self.parser.add_argument('--port', nargs='?', type=int, default=8000) result = parser.parse(self.parser, argv=['command'], no_args_func=lambda option: option.port) self.assertEqual(result, 8000) pass
def test_no_value(self): with self.assertRaises(AttributeError): result = parser.parse(self.parser, argv=['command'], no_args_func=lambda option: option.version) pass pass