def test_version_ok(self, console_mock): for path in (FIXTURE_DIR, USER_DIR, INSTALL_DIR): os.chdir(path) before = os.listdir(path) main.main(['version']) self.assertEqual(before, os.listdir(path)) self.assertEqual(call('Volt %s' % VERSION), console_mock.call_args)
def test_cmd_subcmd_ok(self, console_mock): commands = {'ext': ['engine', 'plugin', 'widget']} for cmd in commands: with patch.object(main.Runner, 'run_%s' % cmd) as run_cmd: for subcmd in commands[cmd]: main.main([cmd, subcmd]) self.assertEqual(call(), run_cmd.call_args) self.assertRaises(SystemExit, main.main, [cmd])
def test_cmd_subcmd_ok(self, console_mock): commands = {"ext": ["engine", "plugin", "widget"]} for cmd in commands: with patch.object(main.Runner, "run_%s" % cmd) as run_cmd: for subcmd in commands[cmd]: main.main([cmd, subcmd]) self.assertEqual(call(), run_cmd.call_args) self.assertRaises(SystemExit, main.main, [cmd])
def test_init_gen_ok(self, console_mock): call2 = call("All engines are inactive -- nothing to generate.", color="red", is_bright=True) self.run_init() before = [x for x in os.listdir(CMD_INIT_DIR) if not (x.endswith(".pyc") or x == "__pycache__")] main.main(["gen"]) after = [x for x in os.listdir(CMD_INIT_DIR) if not (x.endswith(".pyc") or x == "__pycache__")] [x.sort() for x in before, after] self.assertEqual(before, after) self.assertEqual([self.console_call, call2], console_mock.call_args_list)
def test_init_gen_ok(self, console_mock): call2 = call('All engines are inactive -- nothing to generate.', \ color='red', is_bright=True) self.run_init() before = [x for x in os.listdir(CMD_INIT_DIR) if not x.endswith('.pyc')] main.main(['gen']) after = [x for x in os.listdir(CMD_INIT_DIR) if not x.endswith('.pyc')] [x.sort() for x in before, after] self.assertEqual(before, after) self.assertEqual([self.console_call, call2], console_mock.call_args_list)
def test_init_serve_ok(self, console_mock): call2 = call('All engines are inactive -- nothing to generate.', \ color='red', is_bright=True) call3 = call('Site directory not found -- nothing to serve.', \ color='red', is_bright=True) self.run_init() before = [x for x in os.listdir(CMD_INIT_DIR) if \ not (x.endswith('.pyc') or x == '__pycache__')] main.main(['serve']) after = [x for x in os.listdir(CMD_INIT_DIR) if \ not (x.endswith('.pyc') or x == '__pycache__')] [x.sort() for x in before, after] self.assertEqual(before, after) self.assertEqual([self.console_call, call2, call3], console_mock.call_args_list)
def test_cmd_ok(self, console_mock): commands = ['init', 'demo', 'gen', 'serve', 'version'] for cmd in commands: with patch.object(main.Runner, 'run_%s' % cmd) as run_cmd: main.main([cmd]) self.assertEqual([call()], run_cmd.call_args_list)
def run_init(self): if os.path.exists(CMD_INIT_DIR): shutil.rmtree(CMD_INIT_DIR) os.mkdir(CMD_INIT_DIR) os.chdir(CMD_INIT_DIR) main.main(['init'])
def test_cmd_ok(self, console_mock): commands = ["init", "demo", "gen", "serve", "version"] for cmd in commands: with patch.object(main.Runner, "run_%s" % cmd) as run_cmd: main.main([cmd]) self.assertEqual([call()], run_cmd.call_args_list)