def test_cli_init(self): if os.path.isfile('zappa_settings.json'): os.remove('zappa_settings.json') # Test directly zappa_cli = ZappaCLI() # Via http://stackoverflow.com/questions/2617057/how-to-supply-stdin-files-and-environment-variable-inputs-to-python-unit-tests inputs = ['dev', 'lmbda', 'test_settings', ''] input_generator = (i for i in inputs) with mock.patch('__builtin__.raw_input', lambda prompt: next(input_generator)): zappa_cli.init() if os.path.isfile('zappa_settings.json'): os.remove('zappa_settings.json') # Test via handle() input_generator = (i for i in inputs) with mock.patch('__builtin__.raw_input', lambda prompt: next(input_generator)): zappa_cli = ZappaCLI() argv = ['init'] zappa_cli.handle(argv) if os.path.isfile('zappa_settings.json'): os.remove('zappa_settings.json')
def test_cli_error_exit_code(self): # Discussion: https://github.com/Miserlou/Zappa/issues/407 zappa_cli = ZappaCLI() # Sanity argv = '-s test_settings.json status devor'.split() with self.assertRaises(SystemExit) as system_exit: zappa_cli.handle(argv) self.assertEqual(system_exit.exception.code, 1)
def test_cli_default(self): # Discussion: https://github.com/Miserlou/Zappa/issues/422 zappa_cli = ZappaCLI() argv = '-s tests/test_one_env.json status'.split() # It'll fail, but at least it'll cover it. with self.assertRaises(SystemExit) as system_exit: zappa_cli.handle(argv) self.assertEqual(system_exit.exception.code, 1) zappa_cli = ZappaCLI() argv = '-s tests/test_one_env.json status --all'.split() # It'll fail, but at least it'll cover it. with self.assertRaises(SystemExit) as system_exit: zappa_cli.handle(argv) self.assertEqual(system_exit.exception.code, 1) zappa_cli = ZappaCLI() argv = '-s test_settings.json status'.split() with self.assertRaises(SystemExit) as system_exit: zappa_cli.handle(argv) self.assertEqual(system_exit.exception.code, 2)
def test_cli_args(self): zappa_cli = ZappaCLI() # Sanity argv = '-s test_settings.json derp ttt888'.split() zappa_cli.handle(argv)
def test_cli_args(self): zappa_cli = ZappaCLI() # Sanity argv = '-s test_settings.json derp ttt888'.split() zappa_cli.handle(argv)
from zappa.cli import ZappaCLI zappa = ZappaCLI() zappa.handle(["update"])
from zappa.cli import ZappaCLI zappa = ZappaCLI() zappa.handle(["deploy"])