示例#1
0
def main():
    assert "VIRTUAL_ENV" in os.environ, "ERROR: Call me only in a activated virtualenv!"

    path_helper = get_path_helper_instance()
    # path_helper.print_path()
    # path_helper.assert_all_path()

    if path_helper.normal_mode:
        # Installed in "normal" mode (as Package from PyPi)
        ShellClass = PyLucidNormalShell
    else:
        # Installed in "developer" mode (as editable from source)
        # Import here, because developer_shell imports packages that
        # only installed in "developer" mode ;)
        from pylucid.admin_shell.developer_shell import PyLucidDeveloperShell
        ShellClass = PyLucidDeveloperShell

    ShellClass(
        path_helper,
        self_filename=Path(__file__).name
    ).cmdloop()
 def setUpClass(cls):
     super().setUpClass()
     cls.path_helper = get_path_helper_instance()
示例#3
0
 def setUpClass(cls):
     super().setUpClass()
     cls.path_helper = get_path_helper_instance()
class TestPyLucidAdmin(unittest.TestCase):
    """
    Tests for pylucid/pylucid_admin.py
    """
    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.path_helper = get_path_helper_instance()

    def pylucid_admin_run(self, *args):
        args = ("pylucid_admin", ) + args
        try:
            return VerboseSubprocess(*args).verbose_output(check=False)
        except subprocess.CalledProcessError as err:
            self.fail("Subprocess error: %s" % err)

    def test_help(self):
        output = self.pylucid_admin_run("help")
        print(output)

        self.assertIn("pylucid_admin.py shell", output)
        self.assertIn("Available commands (type help <topic>):", output)

        self.assertIn("create_page_instance", output)
        self.assertIn("Create a PyLucid page instance.", output)

        self.assertIn("update_env", output)
        self.assertIn("Update all packages in virtualenv.", output)

        # If DocString is missing in do_<name>():
        self.assertNotIn("Undocumented", output)

    def test_unknown_command(self):
        output = self.pylucid_admin_run("foo bar is unknown ;)")
        print(output)

        self.assertIn("pylucid_admin.py shell", output)
        self.assertIn("*** Unknown command: 'foo bar is unknown ;)' ***", output)

    def test_path_helper(self):
        self.path_helper.print_path()
        self.path_helper.assert_all_path()

    @unittest.skipIf(get_path_helper_instance().normal_mode, "Only available in 'developer' mode.")
    def test_change_editable_address(self):
        """
        All test runs on Travis-CI install PyLucid as editable!
        See .travis.yml
        """
        self.assertFalse(self.path_helper.normal_mode)

        pylucid_src_path = self.path_helper.base.parent
        print("pylucid_src_path: %r" % pylucid_src_path)

        self.assertTrue(pylucid_src_path.is_dir())
        self.assertTrue(str(pylucid_src_path).endswith("/src/pylucid"))

        git_path = Path(pylucid_src_path, ".git")
        print("git_path: %r" % git_path)

        self.assertTrue(git_path.is_dir())

        # Needed while developing with github write access url ;)
        output = VerboseSubprocess(
            "git", "remote", "set-url", "origin", "https://github.com/jedie/PyLucid.git",
            cwd=str(pylucid_src_path)
        ).verbose_output(check=True)
        # print(output)

        # Check if change was ok:
        output = VerboseSubprocess(
            "git", "remote", "-v",
            cwd=str(pylucid_src_path)
        ).verbose_output(check=True)
        # print(output)
        self.assertIn("https://github.com/jedie/PyLucid.git", output)
        self.assertNotIn("*****@*****.**", output)

        output = self.pylucid_admin_run("change_editable_address")
        print(output)

        self.assertIn("[email protected]:jedie/PyLucid.git", output)