Пример #1
0
    def test_restore_last_project(self):
        """Restore last used project."""

        manager = project.ProjectManager(self.mktemp())
        prj = manager.get_project(NAME)
        prj.create()
        settings = Settings(self.mktemp())
        settings.set("current_project", NAME)
        self.assertEqual(manager.restore_last(Factory(), settings), prj)
Пример #2
0
    def test_restore_last_project_not_exists(self):
        """
        If the last project does not exists, don't create a new one with the
        same name but use a default name.
        """

        settings = Settings(self.mktemp())
        settings.set("current_project", NAME)
        manager = project.ProjectManager(self.mktemp())
        prj = manager.get_project(NAME)
        self.assertFalse(prj.exists())
        prj = manager.restore_last(Factory(), settings)
        self.assertEqual(prj.name, settings.DEFAULT_PROJECT + "_0")
Пример #3
0
    def test_open(self):
        """Open a project."""

        manager = project.ProjectManager(self.mktemp())
        prj = manager.get_project(NAME)
        prj.create()
        prj.open(Factory(), Settings(self.mktemp()))
Пример #4
0
    def test_rename_invalid_pathological(self):
        """If the name is really strange, the error is not raised."""

        manager = project.ProjectManager(self.mktemp())
        prj = manager.get_project(NAME)
        prj.create()
        prj.rename("test/../invalid", False, Settings(self.mktemp()))
        self.assertEqual(prj.name, "invalid")
Пример #5
0
    def test_rename(self):
        """Rename a project."""

        NEWNAME = "rename_test"
        manager = project.ProjectManager(self.mktemp())
        prj = manager.get_project(NAME)
        prj.create()
        self.assertTrue(prj.exists())
        old_path = prj.path
        prj.rename(NEWNAME, False, Settings(self.mktemp()))
        self.assertEqual(prj.name, NEWNAME)
        self.assertTrue(prj.exists())
        self.assertNotEqual(prj.path, old_path)
        self.assertFalse(FilePath(old_path).exists())
Пример #6
0
    def test_open_project_set_virtualbricks_home(self):
        """
        Every time a project is opened, settings.VIRTUALBRICKS_HOME is set to
        the project's path.
        """

        manager = project.ProjectManager(self.mktemp())
        settings = Settings(self.mktemp())
        prj = manager.get_project(NAME)
        prj.create()
        self.assertEqual(settings.VIRTUALBRICKS_HOME, settings.DEFAULT_HOME)
        prj.open(Factory(), settings)
        self.assertEqual(prj.path, settings.VIRTUALBRICKS_HOME)
        self.assertNotEqual(settings.VIRTUALBRICKS_HOME, settings.DEFAULT_HOME)