def test_start_project(self): manager = LocalCommandsManager() with nostdout(): self.assertRaises(SystemExit, manager.parse, ['startproject']) self.assertRaises(SystemExit, manager.parse, ['startproject', 'ProjectName', '-m', 'x']) self.assertRaises(SystemExit, manager.parse, ['startproject', 'ProjectName', '-t', 'abc']) # test for invalid project name self.assertRaises(ValueError, manager.parse, ['startproject', '@$']) self.assertRaises(ValueError, manager.parse, ['startproject', 'Projec Name']) # test for generated project contents # create a project in a temporary current working dir tmpdir = tmp_chdir() with nostdout(): manager.parse(['startproject', 'Monte_Carlo_Pi']) files_to_validate = [ 'monte_carlo_pi/client/monte_carlo_pi.js', 'monte_carlo_pi/__init__.py', 'monte_carlo_pi/monte_carlo_pi.py', ] self._validate_content(RES_DIR, tmpdir, files_to_validate)
def test_start_project_coffee(self): manager = LocalCommandsManager() tmpdir = tmp_chdir() with nostdout(): manager.parse(['startproject', 'Pi_Calc', '-t', 'coffee']) files_to_validate = [ 'pi_calc/client/pi_calc.coffee', 'pi_calc/__init__.py', 'pi_calc/pi_calc.py', ] self._validate_content(RES_DIR, tmpdir, files_to_validate)
def test_build(self): lmanager = LocalCommandsManager() env_path = _start_env() os.chdir(env_path) # copy a test 'pi calc' project to the environment res_path = _pjoin(RES_DIR, 'pi_calc') dest_path = _pjoin(env_path, 'pi_calc') shutil.copytree(res_path, dest_path) # test plain is_kaylee_project_directory() sys.path.insert(0, env_path) from kaylee.manager.commands.build import is_kaylee_project_directory self.assertTrue(is_kaylee_project_directory(res_path)) self.assertFalse(is_kaylee_project_directory('/etc')) del sys.path[0] with nostdout(): lmanager.parse(['build']) build_path = os.path.join(env_path, '_build') self.assertTrue(os.path.exists(build_path), build_path) project_files_to_validate = [ 'js/pi_calc.js', 'css/pi_calc.css', 'css/other.css', 'js/somelib.js', 'js/otherlib.js', 'data/somedata.dat', 'data/otherdata', ] for fname in project_files_to_validate: fpath = os.path.join(build_path, 'pi_calc', fname) self.assertTrue(os.path.exists(fpath), fpath) kaylee_files_to_validate = [ 'js/kaylee.js', 'js/klworker.js', 'js/kldebug.js', 'js/jquery.min.js', 'css/klconsole.css' ] for fname in kaylee_files_to_validate: fpath = os.path.join(build_path, 'kaylee', fname) self.assertTrue(os.path.exists(fpath))
def main(): from kaylee.manager import LocalCommandsManager LocalCommandsManager.execute_from_command_line()