Esempio n. 1
0
 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'),
     )
Esempio n. 2
0
 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'),
     )
Esempio n. 3
0
    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())
Esempio n. 4
0
    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),
        )
Esempio n. 5
0
def _get_env():
    template_path = os.path.join(
        PathResolver.theme_dir('simple'),
        'templates',
    )
    loader = FileSystemLoader(template_path)
    env = Environment(loader=loader)
    return env
Esempio n. 6
0
 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)
Esempio n. 7
0
    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',
        )
Esempio n. 8
0
 def setUp(self):
     self.project_path = self._get_file_path('')
     PathResolver.set_project_path(self.project_path)
Esempio n. 9
0
 def __enter__(self):
     os.chdir(PathResolver.outputs())
Esempio n. 10
0
 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
Esempio n. 11
0
 def _get_dir_path_of_inpouts(self, dirname):
     dir_path = os.path.join(
         PathResolver.inputs(),
         dirname,
     )
     return dir_path
Esempio n. 12
0
 def base_path(self):
     return PathResolver.theme_dir(self.THEME)
Esempio n. 13
0
 def base_path(self):
     return PathResolver.inputs()