~ubuntu-branches/ubuntu/trusty/pitivi/trusty

« back to all changes in this revision

Viewing changes to tests/test_formatters_base.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-07-07 13:43:47 UTC
  • mto: (6.1.9 sid) (1.2.12)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20110707134347-cari9kxjiakzej9z
Tags: upstream-0.14.1
ImportĀ upstreamĀ versionĀ 0.14.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# PiTiVi , Non-linear video editor
 
3
#
 
4
#       test_formatters_base.py
 
5
#
 
6
# Copyright (c) 2011, Alex Balut <alexandru.balut@gmail.com>
 
7
#
 
8
# This program is free software; you can redistribute it and/or
 
9
# modify it under the terms of the GNU Lesser General Public
 
10
# License as published by the Free Software Foundation; either
 
11
# version 2.1 of the License, or (at your option) any later version.
 
12
#
 
13
# This program is distributed in the hope that it will be useful,
 
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
# Lesser General Public License for more details.
 
17
#
 
18
# You should have received a copy of the GNU Lesser General Public
 
19
# License along with this program; if not, write to the
 
20
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 
21
# Boston, MA 02110-1301, USA.
 
22
 
 
23
import shutil
 
24
import tempfile
 
25
 
 
26
from pitivi.formatters.base import Formatter
 
27
 
 
28
from common import TestCase
 
29
 
 
30
 
 
31
class TestFormatter(TestCase):
 
32
 
 
33
    def setUp(self):
 
34
        TestCase.setUp(self)
 
35
        self.formatter = Formatter(avalaible_effects=None)
 
36
 
 
37
    def testSearchMissingFile(self):
 
38
        # The scenario is that a file has been moved from dir1 to dir2.
 
39
        dir0 = tempfile.mkdtemp()
 
40
        try:
 
41
            dir1 = tempfile.mkdtemp(dir=dir0)
 
42
            dir2 = tempfile.mkdtemp(dir=dir0)
 
43
            unused_file2, file2_path = tempfile.mkstemp(dir=dir2)
 
44
            uri2 = 'file://%s' % file2_path
 
45
            uri1 = uri2.replace(dir2, dir1)
 
46
 
 
47
            self.assertIsNone(self.formatter._searchMissingFile(uri1))
 
48
 
 
49
            self.formatter.addMapping('file://%s' % dir1, 'file://%s' % dir2)
 
50
            self.assertEqual(uri2, self.formatter._searchMissingFile(uri1))
 
51
        finally:
 
52
            shutil.rmtree(dir0)