def test_project_and_theme_settings(self): self.assertEqual( PathResolver.project_settings(), self._get_file_path('settings'), ) self.assertEqual( PathResolver.theme_settings('testtheme'), self._get_file_path('themes/testtheme/settings'), )
def test_theme_state_and_dir(self): self.assertEqual( PathResolver.theme_state('testtheme'), self._get_file_path('states/testtheme'), ) self.assertEqual( PathResolver.theme_dir('testtheme'), self._get_file_path('themes/testtheme'), )
def test_check_cwd_is_project(self): not_project_path = self._get_file_path('') project_path = os.path.join( os.getcwd(), 'tests/cases/project', ) PathResolver.set_project_path(not_project_path) self.assertFalse(check_cwd_is_project()) PathResolver.set_project_path(project_path) self.assertTrue(check_cwd_is_project())
def test_not_in_project(self): not_project_path = self._get_path('tests/cases') PathResolver.set_project_path(not_project_path) template = 'simple' sys.argv = ['geekcms', 'startproject', template] self.assertEqual( _not_in_project(), template, ) shutil.rmtree( os.path.join(not_project_path, template), )
def _get_env(): template_path = os.path.join( PathResolver.theme_dir('simple'), 'templates', ) loader = FileSystemLoader(template_path) env = Environment(loader=loader) return env
def run(self): dir_path = os.path.join( PathResolver.theme_dir('simple'), 'static', ) manager = self.get_manager_bind_with_plugin(StaticFileOfThemeSimple) for abs_path in self._load_files_in_dir(dir_path): manager.create(abs_path)
def test_in_project(self): project_path = self._get_path('tests/cases/project') PathResolver.set_project_path(project_path) sys.argv = ['geekcms', 'run'] command = _in_project() self.assertEqual( command, 'run', ) sys.argv = ['geekcms', 'testcmd', '-a', '-b', 'c', 'd'] command = _in_project() self.assertEqual( command, 'testcmd', )
def setUp(self): self.project_path = self._get_file_path('') PathResolver.set_project_path(self.project_path)
def __enter__(self): os.chdir(PathResolver.outputs())
def _get_xml_abs_path(self): xml_path = os.path.join( PathResolver.theme_state('simple', ensure_exist=True), self.XML_REL_PATH, ) return xml_path
def _get_dir_path_of_inpouts(self, dirname): dir_path = os.path.join( PathResolver.inputs(), dirname, ) return dir_path
def base_path(self): return PathResolver.theme_dir(self.THEME)
def base_path(self): return PathResolver.inputs()