[pitivi] Fix unit tests



commit 62d4ee995b169923aaefd433c3fce26e167a2b5b
Author: Thibault Saunier <tsaunier gnome org>
Date:   Mon Jun 1 18:17:40 2015 +0200

    Fix unit tests
    
    Adding dedicated code path to run Pitivi without launching it UI is
    not the best thing to do but we need to be able to do that in the
    unit tests.

 pitivi/undo/timeline.py     |   14 +++++++-------
 pitivi/utils/timeline.py    |    2 ++
 tests/test_undo_timeline.py |    2 --
 3 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index 62b2ea9..158cf35 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -20,7 +20,6 @@
 # Boston, MA 02110-1301, USA.
 
 from gi.repository import Gst
-from gi.repository import GstController
 from gi.repository import GES
 from gi.repository import GObject
 
@@ -143,8 +142,7 @@ class TrackElementAdded(UndoableAction):
         props = self.track_element.list_children_properties()
         self.track_element_props = [(prop.name, self.track_element.get_child_property(prop.name)[1])
                                     for prop in props
-                                    if prop.flags & GObject.PARAM_WRITABLE
-                                    and prop.name not in PROPS_TO_IGNORE]
+                                    if prop.flags & GObject.PARAM_WRITABLE and prop.name not in 
PROPS_TO_IGNORE]
         self.clip.remove(self.track_element)
         self._props_changed =\
             self._properties_watcher.getPropChangedFromTrackElement(
@@ -179,8 +177,7 @@ class TrackElementRemoved(UndoableAction):
         props = self.track_element.list_children_properties()
         self.track_element_props = [(prop.name, self.track_element.get_child_property(prop.name)[1])
                                     for prop in props
-                                    if prop.flags & GObject.PARAM_WRITABLE
-                                    and prop.name not in PROPS_TO_IGNORE]
+                                    if prop.flags & GObject.PARAM_WRITABLE and prop.name not in 
PROPS_TO_IGNORE]
 
         self.clip.remove(self.track_element)
 
@@ -320,10 +317,11 @@ class ClipAdded(UndoableAction):
         self._undone()
 
     def asScenarioAction(self):
+        timeline = self.layer.get_timeline()
         if hasattr(self.layer, "splitting_object") and \
                 self.layer.splitting_object is True:
             return None
-        elif self.layer.get_timeline().ui.editing_context is not None:
+        elif hasattr(timeline, "ui") and timeline.ui and timeline.ui.editing_context is not None:
             return None
 
         st = Gst.Structure.new_empty("add-clip")
@@ -356,7 +354,9 @@ class ClipRemoved(UndoableAction):
         self._undone()
 
     def asScenarioAction(self):
-        if self.layer.get_timeline().ui.editing_context is not None:
+        timeline = self.layer.get_timeline()
+        if hasattr(timeline, "ui") and timeline.ui\
+                and timeline.ui.editing_context is not None:
             return None
 
         st = Gst.Structure.new_empty("remove-clip")
diff --git a/pitivi/utils/timeline.py b/pitivi/utils/timeline.py
index dcff246..9b3c5ef 100644
--- a/pitivi/utils/timeline.py
+++ b/pitivi/utils/timeline.py
@@ -152,6 +152,8 @@ class Selection(GObject.Object, Loggable):
                     element.selected.selected = False
 
         for obj in self.selected - old_selection:
+            if not hasattr(obj, "ui") or not obj.ui:
+                continue
             ui.set_children_state_recurse(obj.ui, Gtk.StateFlags.SELECTED)
             for element in obj.get_children(False):
                 if not isinstance(element, GES.BaseEffect) and not isinstance(element, GES.TextOverlay):
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 9558a98..4fb63e7 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -31,9 +31,7 @@ from pitivi.undo.timeline import TimelineLogObserver, \
     ClipAdded, ClipRemoved, \
     ClipPropertyChanged, TrackElementAdded
 from pitivi.undo.undo import UndoableActionLog
-from pitivi.project import Project
 from pitivi.application import Pitivi
-from pitivi.utils.loggable import Loggable
 
 
 class TimelineLogObserverSpy(TimelineLogObserver):


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