[pitivi] Add tests for ProjectManager.newBlankProject.



commit 42eef026316ba5018aac99e15cfdb514b35ba0d5
Author: Alessandro Decina <alessandro d gmail com>
Date:   Fri Jun 5 16:11:43 2009 +0200

    Add tests for ProjectManager.newBlankProject.
---
 pitivi/projectmanager.py     |    4 +++-
 tests/test_projectmanager.py |   24 +++++++++++++++++++++---
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/pitivi/projectmanager.py b/pitivi/projectmanager.py
index a4130fb..bfd3eda 100644
--- a/pitivi/projectmanager.py
+++ b/pitivi/projectmanager.py
@@ -93,7 +93,7 @@ class ProjectManager(Signallable, Loggable):
         """ start up a new blank project """
         # if there's a running project we must close it
         if self.current is not None and not self.closeRunningProject():
-            return
+            return False
 
         # we don't have an URI here, None means we're loading a new project
         self.emit("new-project-loading", None)
@@ -111,6 +111,8 @@ class ProjectManager(Signallable, Loggable):
 
         self.emit("new-project-loaded", self.current)
 
+        return True
+
 
     def _getFormatterForUri(self, uri):
         return get_formatter_for_uri(uri)
diff --git a/tests/test_projectmanager.py b/tests/test_projectmanager.py
index 5939697..de80579 100644
--- a/tests/test_projectmanager.py
+++ b/tests/test_projectmanager.py
@@ -221,7 +221,6 @@ class TestProjectManager(TestCase):
         name, args = self.signals[0]
         self.failUnlessEqual(name, "closing-project")
         project = args[0]
-        self.failUnlessEqual(True, True)
         self.failUnless(project is self.manager.current)
 
     def testCloseRunningProject(self):
@@ -232,13 +231,32 @@ class TestProjectManager(TestCase):
         name, args = self.signals[0]
         self.failUnlessEqual(name, "closing-project")
         project = args[0]
-        self.failUnlessEqual(True, True)
         self.failUnless(project is current)
 
         name, args = self.signals[1]
         self.failUnlessEqual(name, "project-closed")
         project = args[0]
-        self.failUnlessEqual(True, True)
         self.failUnless(project is current)
 
         self.failUnlessEqual(self.manager.current, None)
+
+    def testNewBlankProjectCantCloseCurrent(self):
+        current = self.manager.current = MockProject()
+        current.save = lambda: False
+
+        self.failIf(self.manager.newBlankProject())
+        self.failIf(self.signals)
+
+    def testNewBlankProject(self):
+        self.failUnless(self.manager.newBlankProject())
+        self.failUnlessEqual(len(self.signals), 2)
+
+        name, args = self.signals[0]
+        self.failUnlessEqual(name, "new-project-loading")
+        uri = args[0]
+        self.failUnlessEqual(uri, None)
+
+        name, args = self.signals[1]
+        self.failUnlessEqual(name, "new-project-loaded")
+        project = args[0]
+        self.failUnless(project is self.manager.current)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]