[pitivi] project: Change method to return the project
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] project: Change method to return the project
- Date: Fri, 8 Feb 2019 06:47:09 +0000 (UTC)
commit aa5a274538b033d85ec1200b7fc683bb080ff82d
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Sun Jan 27 23:13:51 2019 +0100
project: Change method to return the project
pitivi/greeterperspective.py | 2 +-
pitivi/project.py | 6 +++---
tests/common.py | 9 +++------
tests/test_media_library.py | 2 +-
tests/test_project.py | 12 +++++-------
tests/test_undo_project.py | 4 +---
tests/test_undo_timeline.py | 5 ++---
7 files changed, 16 insertions(+), 24 deletions(-)
---
diff --git a/pitivi/greeterperspective.py b/pitivi/greeterperspective.py
index 77e2a46e..56d3bfa5 100644
--- a/pitivi/greeterperspective.py
+++ b/pitivi/greeterperspective.py
@@ -315,7 +315,7 @@ class GreeterPerspective(Perspective):
self.app.project_manager.loadProject(uri)
def __new_project_cb(self, unused_action, unused_param):
- self.app.project_manager.newBlankProject()
+ self.app.project_manager.new_blank_project()
def __open_project_cb(self, unused_action, unused_param):
dialog = BrowseProjectsDialog(self.app)
diff --git a/pitivi/project.py b/pitivi/project.py
index 984a540a..add96b65 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -509,11 +509,11 @@ class ProjectManager(GObject.Object, Loggable):
return True
- def newBlankProject(self):
+ def new_blank_project(self):
"""Creates a new blank project and sets it as the current project.
Returns:
- bool: Whether the project has been created successfully.
+ Project: The created project.
"""
self.debug("New blank project")
@@ -539,7 +539,7 @@ class ProjectManager(GObject.Object, Loggable):
project.loaded = True
self.time_loaded = time.time()
- return True
+ return project
def revertToSavedProject(self):
"""Discards all unsaved changes and reloads the current open project."""
diff --git a/tests/common.py b/tests/common.py
index 704270b1..68638fce 100644
--- a/tests/common.py
+++ b/tests/common.py
@@ -104,8 +104,7 @@ def create_pitivi_mock(**settings):
def create_project():
project_manager = ProjectManager(create_pitivi_mock())
- project_manager.newBlankProject()
- project = project_manager.current_project
+ project = project_manager.new_blank_project()
return project
@@ -119,15 +118,13 @@ def create_pitivi(**settings):
def create_timeline_container():
app = create_pitivi_mock(leftClickAlsoSeeks=False)
- project_manager = ProjectManager(app)
- project_manager.newBlankProject()
- project = project_manager.current_project
+ app.project_manager = ProjectManager(app)
+ project = app.project_manager.new_blank_project()
timeline_container = TimelineContainer(app)
timeline_container.setProject(project)
timeline = timeline_container.timeline
- timeline.app.project_manager.current_project = project
timeline.get_parent = mock.MagicMock(return_value=timeline_container)
app.gui.timeline_ui = timeline_container
diff --git a/tests/test_media_library.py b/tests/test_media_library.py
index 3fcf8777..a7f9e0e7 100644
--- a/tests/test_media_library.py
+++ b/tests/test_media_library.py
@@ -65,7 +65,7 @@ class BaseTestMediaLibrary(common.TestCase):
if project_uri:
self.app.project_manager.loadProject(project_uri)
else:
- self.app.project_manager.newBlankProject()
+ self.app.project_manager.new_blank_project()
self.app.project_manager.current_project.connect(
"loaded", self.projectLoadedCb)
diff --git a/tests/test_project.py b/tests/test_project.py
index 7fbcfe67..00bbf234 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -90,7 +90,7 @@ class TestProjectManager(common.TestCase):
self.assertEqual(uri, signalUri, self.signals)
def testLoadProject(self):
- self.manager.newBlankProject()
+ self.manager.new_blank_project()
name, args = self.signals[0]
self.assertEqual("new-project-loading", name, self.signals)
@@ -177,7 +177,7 @@ class TestProjectManager(common.TestCase):
self.assertTrue(self.manager.current_project is None)
def testNewBlankProject(self):
- self.assertTrue(self.manager.newBlankProject())
+ self.assertIsNotNone(self.manager.new_blank_project())
self.assertEqual(3, len(self.signals))
name, args = self.signals[0]
@@ -196,7 +196,7 @@ class TestProjectManager(common.TestCase):
self.assertTrue(project is self.manager.current_project)
def testSaveProject(self):
- self.assertTrue(self.manager.newBlankProject())
+ self.manager.new_blank_project()
unused, path = tempfile.mkstemp(suffix=".xges")
unused, path2 = tempfile.mkstemp(suffix=".xges")
@@ -240,7 +240,7 @@ class TestProjectManager(common.TestCase):
self.assertEqual(uri + "~", self.manager._makeBackupURI(uri))
def testBackupProject(self):
- self.manager.newBlankProject()
+ self.manager.new_blank_project()
# Assign an uri to the project where it's saved by default.
unused, xges_path = tempfile.mkstemp(suffix=".xges")
@@ -296,9 +296,7 @@ class TestProjectLoading(common.TestCase):
def test_asset_added_signal(self):
app = common.create_pitivi()
- self.assertTrue(app.project_manager.newBlankProject())
-
- project = app.project_manager.current_project
+ project = app.project_manager.new_blank_project()
proxy_manager = app.proxy_manager
mainloop = common.create_main_loop()
diff --git a/tests/test_undo_project.py b/tests/test_undo_project.py
index 3f8630f4..600a871f 100644
--- a/tests/test_undo_project.py
+++ b/tests/test_undo_project.py
@@ -28,9 +28,7 @@ class TestProjectUndo(common.TestCase):
def setUp(self):
super(TestProjectUndo, self).setUp()
self.app = common.create_pitivi()
- self.assertTrue(self.app.project_manager.newBlankProject())
-
- self.project = self.app.project_manager.current_project
+ self.project = self.app.project_manager.new_blank_project()
self.action_log = self.app.action_log
def test_new_project_has_nothing_to_undo(self):
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 4c6d6757..7bca226e 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -43,9 +43,8 @@ class BaseTestUndoTimeline(common.TestCase):
def setUp(self):
super(BaseTestUndoTimeline, self).setUp()
self.app = common.create_pitivi()
- self.app.project_manager.newBlankProject()
-
- self.timeline = self.app.project_manager.current_project.ges_timeline
+ project = self.app.project_manager.new_blank_project()
+ self.timeline = project.ges_timeline
self.layer = self.timeline.append_layer()
self.action_log = self.app.action_log
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]