def _start_env(name='tenv'): amanager = AdminCommandsManager() tmpdir = tmp_chdir() env_path = os.path.abspath(_pjoin(tmpdir, name)) with nostdout(): amanager.parse(['startenv', 'tenv']) return env_path
def test_start_env(self): manager = AdminCommandsManager() with nostdout(): self.assertRaises(SystemExit, manager.parse, ['startenv']) tmpdir = tmp_chdir() with nostdout(): manager.parse(['startenv', 'klenv']) # test whether files exist files_to_validate = [ 'klenv/klmanage.py', 'klenv/settings.py', ] for fpath in files_to_validate: full_path = _pjoin(tmpdir, fpath) self.assertGreater(os.path.getsize(full_path), 0) self.assertTrue(os.stat(_pjoin(tmpdir, 'klenv/klmanage.py')).st_mode & stat.S_IEXEC) # test settings contents settings_path = _pjoin(tmpdir, 'klenv/settings.py') settings = imp.load_source('tsettings', settings_path) self.assertEqual(settings.PROJECTS_DIR, _pjoin(tmpdir, 'klenv')) # test 'startenv .' case tmpdir = tmp_chdir() with nostdout(): manager.parse(['startenv', '.']) files_to_validate = [ 'klmanage.py', 'settings.py', ] for fpath in files_to_validate: full_path = _pjoin(tmpdir, fpath) self.assertGreater(os.path.getsize(full_path), 0)
#!/usr/bin/env python from kaylee.manager import AdminCommandsManager if __name__ == '__main__': AdminCommandsManager.execute_from_command_line()