Commit 3e214c78 authored by Alexandru Băluț's avatar Alexandru Băluț

tests: Switch most of the tests to use common.TestCase

parent 9079e640
......@@ -18,7 +18,6 @@
# Boston, MA 02110-1301, USA.
"""Tests for the pitivi.clipproperties module."""
# pylint: disable=protected-access,no-self-use,too-many-locals
import unittest
from unittest import mock
from gi.repository import Gtk
......@@ -29,7 +28,7 @@ from tests import common
from tests.test_timeline_timeline import BaseTestTimeline
class EffectPropertiesTest(unittest.TestCase):
class EffectPropertiesTest(common.TestCase):
"""Tests for the EffectProperties class."""
def test_calculate_effect_priority(self):
......
......@@ -17,22 +17,19 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
"""Tests for the effects module."""
import unittest
from gi.repository import GES
from pitivi.effects import AUDIO_EFFECT
from pitivi.effects import EffectInfo
from pitivi.effects import VIDEO_EFFECT
from tests.common import create_timeline_container
from tests.common import get_sample_uri
from tests import common
class EffectInfoTest(unittest.TestCase):
class EffectInfoTest(common.TestCase):
"""Tests for the EffectInfo class."""
def test_bin_description(self):
"""Tests the bin_description property."""
"""Checks the bin_description property."""
effect_info = EffectInfo("name", None, None, None, None)
self.assertEqual(effect_info.bin_description, "name")
......@@ -40,18 +37,18 @@ class EffectInfoTest(unittest.TestCase):
self.assertEqual(effect_info.bin_description, "glupload ! glname ! gldownload")
def test_name_from_bin_description(self):
"""Tests the name_from_bin_description method."""
"""Checks the name_from_bin_description method."""
self.assertEqual(EffectInfo.name_from_bin_description("name"), "name")
self.assertEqual(EffectInfo.name_from_bin_description("glupload ! glname ! gldownload"), "glname")
def test_good_for_track_element(self):
"""Tests the good_for_track_element method."""
uri = get_sample_uri("tears_of_steel.webm")
"""Checks the good_for_track_element method."""
uri = common.get_sample_uri("tears_of_steel.webm")
asset = GES.UriClipAsset.request_sync(uri)
ges_clip = asset.extract()
# Add the clip to a timeline so it gets tracks.
ges_timeline = create_timeline_container().timeline.ges_timeline
ges_timeline = common.create_timeline_container().timeline.ges_timeline
ges_timeline.append_layer()
ges_layer, = ges_timeline.get_layers()
ges_layer.add_clip(ges_clip)
......
......@@ -19,21 +19,19 @@
"""Tests for the utils.misc module."""
# pylint: disable=protected-access,no-self-use
import os
import unittest
from gi.repository import Gst
from pitivi.utils.misc import PathWalker
from tests.common import create_main_loop
from tests.common import get_sample_uri
from tests import common
class PathWalkerTest(unittest.TestCase):
class PathWalkerTest(common.TestCase):
"""Tests for the `PathWalker` class."""
def _scan(self, uris):
"""Uses the PathWalker to scan URIs."""
mainloop = create_main_loop()
mainloop = common.create_main_loop()
received_uris = []
def done_cb(uris): # pylint: disable=missing-docstring
......@@ -46,9 +44,9 @@ class PathWalkerTest(unittest.TestCase):
def test_scanning(self):
"""Checks the scanning of the URIs."""
valid_uri = get_sample_uri("tears_of_steel.webm")
valid_uri = common.get_sample_uri("tears_of_steel.webm")
uris = self._scan([valid_uri,
get_sample_uri("missing.webm"),
common.get_sample_uri("missing.webm"),
"http://pitivi.org/very_real.webm"])
self.assertEqual(len(uris), 1, uris)
self.assertIn(valid_uri, uris)
......@@ -60,5 +58,5 @@ class PathWalkerTest(unittest.TestCase):
uris = [valid_dir_uri]
received_uris = self._scan(uris)
self.assertGreater(len(received_uris), 1, received_uris)
valid_uri = get_sample_uri("tears_of_steel.webm")
valid_uri = common.get_sample_uri("tears_of_steel.webm")
self.assertIn(valid_uri, received_uris)
......@@ -16,26 +16,26 @@
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
"""Test the Plugin Manager"""
"""Tests for the pluginmanager module."""
import os
import tempfile
import unittest
from unittest import mock
from gi.repository import GObject
from pitivi.pluginmanager import PluginManager
from pitivi.settings import GlobalSettings
from tests import common
class TestPluginManager(unittest.TestCase):
"""Test the behavior of the Plugin Manager"""
class TestPluginManager(common.TestCase):
"""Tests for the Plugin Manager."""
def test_load_plugins_from_settings(self):
"""Checks if the plugin manager loads plugins from GlobalSettings."""
class App(GObject.Object):
"""A representation of the Pitivi Application for test purposes"""
"""A representation of the Pitivi Application for test purposes."""
__gsignals__ = {
"window-added": (GObject.SIGNAL_RUN_LAST, None, (object, ))
}
......
......@@ -16,12 +16,11 @@
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
import unittest
from pitivi.dialogs.prefs import PreferencesDialog
from tests import common
class PreferencesDialogTest(unittest.TestCase):
class PreferencesDialogTest(common.TestCase):
def testNumeric(self):
PreferencesDialog.addNumericPreference('numericPreference1',
......
......@@ -21,11 +21,11 @@
import os.path
import shutil
import tempfile
from unittest import TestCase
from pitivi.preset import AudioPresetManager
from pitivi.preset import PresetManager
from pitivi.utils.system import System
from tests import common
def clearPresetManagerPaths(preset_manager):
......@@ -49,7 +49,7 @@ def countUserPresets(preset_manager):
return countJsonFilesIn(preset_manager.user_path)
class TestPresetBasics(TestCase):
class TestPresetBasics(common.TestCase):
def setUp(self):
self.manager = PresetManager(None, tempfile.mkdtemp(), System())
......@@ -108,7 +108,7 @@ class TestPresetBasics(TestCase):
self.assertEqual('New preset 3', new_preset3)
class TestAudioPresetsIO(TestCase):
class TestAudioPresetsIO(common.TestCase):
def setUp(self):
self.manager = AudioPresetManager(System())
......
......@@ -22,7 +22,6 @@ import os
import tempfile
import time
from unittest import mock
from unittest import TestCase
from gi.repository import GES
from gi.repository import Gst
......@@ -59,9 +58,10 @@ class ProjectManagerListener(object):
return True
class TestProjectManager(TestCase):
class TestProjectManager(common.TestCase):
def setUp(self):
super(TestProjectManager, self).setUp()
app = mock.MagicMock()
self.manager = ProjectManager(app)
self.listener = ProjectManagerListener(self.manager)
......@@ -604,7 +604,7 @@ class TestProjectSettings(common.TestCase):
self.assertFalse(project._has_default_audio_settings)
class TestExportSettings(TestCase):
class TestExportSettings(common.TestCase):
def test_master_attributes(self):
self._check_master_attribute("muxer", dependant_attr="containersettings")
......
......@@ -20,14 +20,14 @@
# pylint: disable=missing-docstring
import os
import tempfile
import unittest
from unittest import mock
from pitivi.settings import ConfigError
from pitivi.settings import GlobalSettings
from tests import common
class TestGlobalSettings(unittest.TestCase):
class TestGlobalSettings(common.TestCase):
"""Tests the GlobalSettings class."""
def setUp(self):
......
......@@ -20,12 +20,12 @@
import os
import tempfile
from unittest import mock
from unittest import TestCase
from pitivi.shortcuts import ShortcutsManager
from tests import common
class TestShortcutsManager(TestCase):
class TestShortcutsManager(common.TestCase):
"""Tests for the ShortcutsManager."""
def test_groups(self):
......
......@@ -19,7 +19,6 @@
"""Tests for the timeline.elements module."""
# pylint: disable=protected-access,no-self-use,too-many-locals
from unittest import mock
from unittest import TestCase
from gi.overrides import GObject
from gi.repository import Gdk
......@@ -31,9 +30,8 @@ from matplotlib.backend_bases import MouseEvent
from pitivi.timeline.elements import GES_TYPE_UI_TYPE
from pitivi.undo.undo import UndoableActionLog
from pitivi.utils.timeline import Zoomable
from tests.common import create_test_clip
from tests.common import create_timeline_container
from tests.test_timeline_timeline import BaseTestTimeline
from tests import common
class TestKeyframeCurve(BaseTestTimeline):
......@@ -41,7 +39,7 @@ class TestKeyframeCurve(BaseTestTimeline):
def test_keyframe_toggle(self):
"""Checks keyframes toggling at the playhead position."""
timeline_container = create_timeline_container()
timeline_container = common.create_timeline_container()
timeline_container.app.action_log = UndoableActionLog()
timeline = timeline_container.timeline
ges_layer = timeline.ges_timeline.append_layer()
......@@ -49,7 +47,7 @@ class TestKeyframeCurve(BaseTestTimeline):
ges_clip2 = self.add_clip(ges_layer, 10, duration=2 * Gst.SECOND)
ges_clip3 = self.add_clip(ges_layer, 20, inpoint=100, duration=2 * Gst.SECOND)
# For variety, add TitleClip to the list of clips.
ges_clip4 = create_test_clip(GES.TitleClip)
ges_clip4 = common.create_test_clip(GES.TitleClip)
ges_clip4.props.start = 30
ges_clip4.props.duration = int(0.9 * Gst.SECOND)
ges_layer.add_clip(ges_clip4)
......@@ -205,7 +203,7 @@ class TestKeyframeCurve(BaseTestTimeline):
def test_no_clip_selected(self):
"""Checks nothing happens when no clip is selected."""
timeline_container = create_timeline_container()
timeline_container = common.create_timeline_container()
# Make sure this does not raise any exception
timeline_container._keyframe_cb(None, None)
......@@ -215,7 +213,7 @@ class TestVideoSource(BaseTestTimeline):
def test_video_source_scaling(self):
"""Checks the size of the scaled clips."""
timeline_container = create_timeline_container()
timeline_container = common.create_timeline_container()
timeline = timeline_container.timeline
project = timeline.app.project_manager.current_project
......@@ -271,7 +269,7 @@ class TestVideoSource(BaseTestTimeline):
def test_rotation(self):
"""Checks the size of the clips flipped 90 degrees."""
timeline_container = create_timeline_container()
timeline_container = common.create_timeline_container()
timeline = timeline_container.timeline
clip = self.addClipsSimple(timeline, 1)[0]
......@@ -315,7 +313,7 @@ class TestVideoSource(BaseTestTimeline):
self.assertEqual(height, 400)
class TestClip(TestCase):
class TestClip(common.TestCase):
"""Tests for the Clip class."""
def test_clip_subclasses(self):
......
......@@ -21,12 +21,10 @@ from unittest import mock
from gi.repository import GES
from pitivi.timeline.layer import Layer
from tests.common import create_timeline_container
from tests.common import get_sample_uri
from tests.common import TestCase
from tests import common
class TestLayerControl(TestCase):
class TestLayerControl(common.TestCase):
def test_name(self):
timeline = mock.MagicMock()
......@@ -51,15 +49,15 @@ class TestLayerControl(TestCase):
self.assertEqual(layer.getName(), "Layer 0x")
class TestLayer(TestCase):
class TestLayer(common.TestCase):
def test_check_media_types_when_no_control_ui(self):
ges_layer = GES.Layer()
png = get_sample_uri("flat_colour1_640x480.png")
png = common.get_sample_uri("flat_colour1_640x480.png")
video_clip = GES.UriClipAsset.request_sync(png).extract()
self.assertTrue(ges_layer.add_clip(video_clip))
self.assertEqual(len(ges_layer.get_clips()), 1)
timeline_container = create_timeline_container()
timeline_container = common.create_timeline_container()
timeline = timeline_container.timeline
# This will add widgets for the clips in ges_layer and
# the layer will use checkMediaTypes which updates the
......
......@@ -17,7 +17,6 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
from unittest import mock
from unittest import TestCase
from gi.repository import GES
......@@ -28,9 +27,10 @@ from pitivi.undo.undo import UndoableActionLog
from pitivi.undo.undo import UndoableActionStack
from pitivi.undo.undo import UndoError
from pitivi.undo.undo import UndoWrongStateError
from tests import common
class TestUndoableActionStack(TestCase):
class TestUndoableActionStack(common.TestCase):
def testUndoDo(self):
"""
......@@ -79,7 +79,7 @@ class TestUndoableActionStack(TestCase):
self.assertEqual(action3.undo.call_count, 1)
class TestUndoableActionLog(TestCase):
class TestUndoableActionLog(common.TestCase):
def setUp(self):
self.log = UndoableActionLog()
......@@ -407,7 +407,8 @@ class TestUndoableActionLog(TestCase):
self.assertEqual(len(self.log.undo_stacks), 0)
self.assertEqual(len(self.log.redo_stacks), 0)
class TestGObjectObserver(TestCase):
class TestGObjectObserver(common.TestCase):
def test_property_change(self):
action_log = UndoableActionLog()
......@@ -432,7 +433,7 @@ class TestGObjectObserver(TestCase):
self.assertEqual(action.new_value, 4)
class TestPropertyChangedAction(TestCase):
class TestPropertyChangedAction(common.TestCase):
def test_expand(self):
stack = UndoableActionStack("good one!")
......
......@@ -16,8 +16,6 @@
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
from unittest import TestCase
from gi.repository import GES
from gi.repository import Gtk
......@@ -25,9 +23,10 @@ from pitivi.project import ProjectSettingsDialog
from tests import common
class TestProjectUndo(TestCase):
class TestProjectUndo(common.TestCase):
def setUp(self):
super(TestProjectUndo, self).setUp()
self.app = common.create_pitivi()
self.assertTrue(self.app.project_manager.newBlankProject())
......
......@@ -18,8 +18,6 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
from unittest import mock
from unittest import skip
from unittest import TestCase
from gi.repository import Gdk
from gi.repository import GES
......@@ -40,9 +38,10 @@ from pitivi.utils.ui import URI_TARGET_ENTRY
from tests import common
class BaseTestUndoTimeline(TestCase):
class BaseTestUndoTimeline(common.TestCase):
def setUp(self):
super(BaseTestUndoTimeline, self).setUp()
self.app = common.create_pitivi()
self.app.project_manager.newBlankProject()
......
......@@ -17,7 +17,6 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
from unittest import mock
from unittest import TestCase
from gi.repository import GES
......@@ -29,7 +28,7 @@ from pitivi.utils.timeline import UNSELECT
from tests import common
class TestSelected(TestCase):
class TestSelected(common.TestCase):
def testBoolEvaluation(self):
selected = Selected()
......@@ -42,7 +41,7 @@ class TestSelected(TestCase):
self.assertFalse(selected)
class TestSelection(TestCase):
class TestSelection(common.TestCase):
def testBoolEvaluation(self):
clip1 = mock.MagicMock()
......
......@@ -16,8 +16,6 @@
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
from unittest import TestCase
from gi.repository import Gst
from pitivi.utils.widgets import ChoiceWidget
......@@ -28,9 +26,10 @@ from pitivi.utils.widgets import NumericWidget
from pitivi.utils.widgets import PathWidget
from pitivi.utils.widgets import TextWidget
from pitivi.utils.widgets import ToggleWidget
from tests import common
class TestWidgets(TestCase):
class TestWidgets(common.TestCase):
def testConstruction(self):
widgets = (
......@@ -63,7 +62,7 @@ class TestWidgets(TestCase):
self.assertNotEqual(bad_value, widget.getWidgetValue())
class TestFractionWidget(TestCase):
class TestFractionWidget(common.TestCase):
def test_widget_text(self):
widget = FractionWidget()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment