How to use __main__ method in pyatom

Best Python code snippet using pyatom_python

test_main.py

Source:test_main.py Github

copy

Full Screen

1import unittest2from unittest.mock import Mock, patch3import json4from snowglobe import __main__5class TestArgParser(unittest.TestCase):6 @classmethod7 def setUpClass(cls):8 pass9 @classmethod10 def tearDownClass(cls):11 pass12 def setUp(self):13 pass14 def tearDown(self):15 pass16 def test_parse_args_list(self):17 res = __main__.parse_args(['list'])18 self.assertEqual(res.command, 'list')19 def test_parse_args_template(self):20 res = __main__.parse_args(['template'])21 self.assertEqual(res.command, 'template')22 def test_parse_args_inspect(self):23 res = __main__.parse_args(['inspect', 'NAME'])24 self.assertEqual(res.command, 'inspect')25 self.assertEqual(res.name, 'NAME')26 def test_parse_args_setup(self):27 res = __main__.parse_args(['setup', 'FILE'])28 self.assertEqual(res.command, 'setup')29 self.assertEqual(res.file, 'FILE')30 def test_parse_args_remove(self):31 res = __main__.parse_args(['remove', 'NAME'])32 self.assertEqual(res.command, 'remove')33 self.assertEqual(res.name, 'NAME')34 def test_parse_args_reset(self):35 res = __main__.parse_args(['reset', 'NAME'])36 self.assertEqual(res.command, 'reset')37 self.assertEqual(res.name, 'NAME')38 def test_parse_args_start(self):39 res = __main__.parse_args(['start', 'NAME'])40 self.assertEqual(res.command, 'start')41 self.assertEqual(res.name, 'NAME')42 def test_parse_args_exec(self):43 res = __main__.parse_args(['exec', 'NAME', 'EXEC-NAME'])44 self.assertEqual(res.command, 'exec')45 self.assertEqual(res.name, 'NAME')46 self.assertEqual(res.exec_name, 'EXEC-NAME')47 def test_parse_args_stop(self):48 res = __main__.parse_args(['stop', 'NAME'])49 self.assertEqual(res.command, 'stop')50 self.assertEqual(res.name, 'NAME')51class TestMain(unittest.TestCase):52 @classmethod53 def setUpClass(cls):54 pass55 @classmethod56 def tearDownClass(cls):57 pass58 def setUp(self):59 pass60 def tearDown(self):61 pass62 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'list'])63 @patch('snowglobe.__main__.environment.Environment')64 def test_main_list(self, mocked_environment):65 mocked_environment_object = Mock()66 mocked_environment.return_value = mocked_environment_object67 res = __main__.main()68 mocked_environment_object.list.assert_called_with()69 self.assertEqual(res, 0)70 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'template'])71 @patch('snowglobe.__main__.environment.Environment')72 def test_main_template(self, mocked_environment):73 mocked_environment_object = Mock()74 mocked_environment.return_value = mocked_environment_object75 res = __main__.main()76 mocked_environment_object.template.assert_called_with()77 self.assertEqual(res, 0)78 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'inspect', 'NAME'])79 @patch('snowglobe.__main__.environment.Environment')80 def test_main_inspect(self, mocked_environment):81 mocked_environment_object = Mock()82 mocked_environment.return_value = mocked_environment_object83 res = __main__.main()84 mocked_environment_object.inspect.assert_called_with('NAME')85 self.assertEqual(res, 0)86 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'setup', 'FILE'])87 @patch('snowglobe.__main__.environment.Environment')88 @patch('snowglobe.__main__.open')89 @patch('snowglobe.__main__.print')90 def test_main_setup_file_not_found(self, mocked_print, mocked_open, mocked_environment):91 mocked_environment_object = Mock()92 mocked_environment.return_value = mocked_environment_object93 mocked_open.side_effect = FileNotFoundError94 mocked_print.return_value = None95 res = __main__.main()96 mocked_open.assert_called_with('FILE', 'r')97 self.assertEqual(res, -1)98 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'setup', 'FILE'])99 @patch('snowglobe.__main__.environment.Environment')100 @patch('snowglobe.__main__.open')101 @patch('snowglobe.__main__.json.loads')102 @patch('snowglobe.__main__.print')103 def test_main_setup_json_error(self, mocked_print, mocked_json_loads, mocked_open, mocked_environment):104 mocked_environment_object = Mock()105 mocked_environment.return_value = mocked_environment_object106 mocked_file_handler = Mock()107 mocked_file_handler.__enter__ = Mock()108 mocked_file_handler.__exit__ = Mock()109 mocked_file_handler.__enter__.return_value = mocked_file_handler110 mocked_file_handler.read.return_value = '{"name": "NAME"}'111 mocked_open.return_value = mocked_file_handler112 mocked_json_loads.side_effect = json.JSONDecodeError('', '', 0)113 mocked_print.return_value = None114 res = __main__.main()115 mocked_open.assert_called_with('FILE', 'r')116 self.assertEqual(res, -1)117 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'setup', 'FILE'])118 @patch('snowglobe.__main__.environment.Environment')119 @patch('snowglobe.__main__.open')120 @patch('snowglobe.__main__.json.loads')121 @patch('snowglobe.__main__.print')122 def test_main_setup(self, mocked_print, mocked_json_loads, mocked_open, mocked_environment):123 mocked_environment_object = Mock()124 mocked_environment.return_value = mocked_environment_object125 mocked_file_handler = Mock()126 mocked_file_handler.__enter__ = Mock()127 mocked_file_handler.__exit__ = Mock()128 mocked_file_handler.__enter__.return_value = mocked_file_handler129 mocked_file_handler.read.return_value = '{"name": "NAME"}'130 mocked_open.return_value = mocked_file_handler131 mocked_json_loads.return_value = {'name': 'NAME'}132 mocked_print.return_value = None133 res = __main__.main()134 mocked_open.assert_called_with('FILE', 'r')135 mocked_environment_object.setup.assert_called_with('NAME', {'name': 'NAME'})136 self.assertEqual(res, 0)137 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'remove', 'NAME'])138 @patch('snowglobe.__main__.environment.Environment')139 def test_main_remove(self, mocked_environment):140 mocked_environment_object = Mock()141 mocked_environment.return_value = mocked_environment_object142 res = __main__.main()143 mocked_environment_object.remove.assert_called_with('NAME')144 self.assertEqual(res, 0)145 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'reset', 'NAME'])146 @patch('snowglobe.__main__.environment.Environment')147 def test_main_reset(self, mocked_environment):148 mocked_environment_object = Mock()149 mocked_environment.return_value = mocked_environment_object150 res = __main__.main()151 mocked_environment_object.reset.assert_called_with('NAME')152 self.assertEqual(res, 0)153 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'start', 'NAME'])154 @patch('snowglobe.__main__.environment.Environment')155 def test_main_start(self, mocked_environment):156 mocked_environment_object = Mock()157 mocked_environment.return_value = mocked_environment_object158 res = __main__.main()159 mocked_environment_object.start.assert_called_with('NAME')160 self.assertEqual(res, 0)161 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'exec', 'NAME', 'EXEC-NAME'])162 @patch('snowglobe.__main__.environment.Environment')163 def test_main_exec(self, mocked_environment):164 mocked_environment_object = Mock()165 mocked_environment.return_value = mocked_environment_object166 res = __main__.main()167 mocked_environment_object.exec.assert_called_with('NAME', 'EXEC-NAME')168 self.assertEqual(res, 0)169 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'stop', 'NAME'])170 @patch('snowglobe.__main__.environment.Environment')171 def test_main_stop(self, mocked_environment):172 mocked_environment_object = Mock()173 mocked_environment.return_value = mocked_environment_object174 res = __main__.main()175 mocked_environment_object.stop.assert_called_with('NAME')176 self.assertEqual(res, 0)177 @patch('snowglobe.__main__.sys.argv', ['PROGRAM', 'list'])178 @patch('snowglobe.__main__.environment.Environment')179 @patch('snowglobe.__main__.print')180 def test_main_unexpected_error(self, mocked_print, mocked_environment):181 mocked_environment.side_effect = Exception182 mocked_print.return_value = None183 res = __main__.main()184 self.assertEqual(res, -1)185if __name__ == '__main__':...

Full Screen

Full Screen

setup.py

Source:setup.py Github

copy

Full Screen

1import setuptools, os2readme_path = 'README.md'3if os.path.exists(readme_path):4 with open(readme_path, "r") as f:5 long_description = f.read()6else:7 long_description = 'kcliutils'8setuptools.setup(9 name="kcliutils",10 version="0.1.12",11 author="Kristof",12 description="kcliutils",13 long_description=long_description,14 long_description_content_type="text/markdown",15 url="https://github.com/kkristof200/py_cli_utils",16 packages=setuptools.find_packages(),17 install_requires=[18 'bullet>=2.2.0',19 'jsoncodable>=0.1.7',20 'kcu>=0.0.68',21 'kdependencies>=0.0.4'22 ],23 classifiers=[24 "Programming Language :: Python :: 3.4",25 "Programming Language :: Python :: 3.5",26 "Programming Language :: Python :: 3.6",27 "Programming Language :: Python :: 3.7",28 "Programming Language :: Python :: 3.8",29 "Programming Language :: Python :: 3.9",30 "License :: OSI Approved :: MIT License",31 "Operating System :: OS Independent",32 ],33 entry_points={34 'console_scripts': [35 # Package related36 'new_python_package=kcliutils.__main__:new_package',37 'npp=kcliutils.__main__:new_package',38 'upgrade_python_package=kcliutils.__main__:upgrade',39 'upp=kcliutils.__main__:upgrade',40 'publish_python_package=kcliutils.__main__:publish',41 'ppp=kcliutils.__main__:publish',42 'publish_and_push_python_package=kcliutils.__main__:publish_and_push',43 'pipush=kcliutils.__main__:publish_and_push',44 'upgrade_push_install=kcliutils.__main__:upgrade_push_install',45 'prpipush=kcliutils.__main__:upgrade_push_install',46 # Formatting47 'clean_lines=kcliutils.__main__:clean_lines',48 'cl=kcliutils.__main__:clean_lines',49 'migrate_comment_line_len=kcliutils.__main__:migrate_comment_line_len',50 # Git51 'push=kcliutils.__main__:push',52 'psh=kcliutils.__main__:push',53 'fetch=kcliutils.__main__:fetch',54 'ftch=kcliutils.__main__:fetch',55 'pull=kcliutils.__main__:pull',56 'pll=kcliutils.__main__:pull',57 # Pip58 'pip_uninstall=kcliutils.__main__:uninstall',59 'pipu=kcliutils.__main__:uninstall',60 'pip_install=kcliutils.__main__:install',61 'pipi=kcliutils.__main__:install',62 'pipiu=kcliutils.__main__:install',63 'pip_reinstall=kcliutils.__main__:reinstall',64 'pipir=kcliutils.__main__:reinstall',65 # New files66 'python_requirements=kcliutils.__main__:create_requirements_file',67 'pyreqs=kcliutils.__main__:create_requirements_file',68 'create_python_install_file=kcliutils.__main__:create_install_file',69 'pif=kcliutils.__main__:create_install_file',70 'new_python_api=kcliutils.__main__:create_new_api',71 'npa=kcliutils.__main__:create_new_api',72 'new_python_class=kcliutils.__main__:create_new_class',73 'npc=kcliutils.__main__:create_new_class',74 'new_python_class_from_json=kcliutils.__main__:create_class_from_json',75 'npcj=kcliutils.__main__:create_class_from_json',76 'new_python_enum=kcliutils.__main__:create_new_enum',77 'npe=kcliutils.__main__:create_new_enum',78 'new_python_file=kcliutils.__main__:create_new_file',79 'npf=kcliutils.__main__:create_new_file',80 'new_python_flow=kcliutils.__main__:create_new_flow',81 'npfl=kcliutils.__main__:create_new_flow',82 'new_python_subpackage=kcliutils.__main__:create_new_subpackage',83 'nps=kcliutils.__main__:create_new_subpackage'84 ]85 },86 python_requires='>=3.4',...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful