File: mediascenario.py

package info (click to toggle)
gst-qa-system 0.0%2Bgit20110920.4750a8e8-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 980 kB
  • sloc: python: 8,498; xml: 855; makefile: 42
file content (64 lines) | stat: -rw-r--r-- 2,138 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# GStreamer QA system
#
#       tests/scenario/mediascenario.py
#
# Copyright (c) 2007, Edward Hervey <bilboed@bilboed.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

"""
Simple media-based scenarios
"""

from insanity.scenario import ListScenario
from insanity.tests.ismedia import IsMediaTest

class MediaBarrierScenario(ListScenario):

    __test_name__ = """media-barrier-scenario"""
    __test_description__ = """
    Only runs the given subtests if the uri/file is a usable media type
    """
    __test_full_description__ = """
    This scenario will first check the mime-type of the given uri/file
    and if it is not a useable media type, will return without executing
    the given tests.
    """
    __non_media_types__ = [
        "application/x-rar",
        "application/zip",
        "application/x-gzip",
        "text/plain"
        ]

    def setUp(self):
        if not ListScenario.setUp(self):
            return False
        # first add a typefind test
        self.addSubTest(IsMediaTest,
                        self.arguments,
                        [], position=0)
        return True

    def subTestDone(self, test):
        if ListScenario.subTestDone(self, test) == False:
            return False
        if isinstance(test, IsMediaTest):
            # get the type
            mtype = test.getExtraInfo()["mime-type"]
            if mtype in self.__non_media_types__:
                return False
        return True