2016-01-22 20:12:46 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2016-12-31 11:01:36 +00:00
|
|
|
# Copyright (c) 2008-2017 OpenLP Developers #
|
2016-01-22 20:12:46 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# 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 General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU 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 #
|
|
|
|
###############################################################################
|
|
|
|
"""
|
|
|
|
Package to test the openlp.core.ui.media package.
|
|
|
|
"""
|
|
|
|
from unittest import TestCase
|
|
|
|
|
|
|
|
from openlp.core.ui.media.vendor.mediainfoWrapper import MediaInfoWrapper
|
|
|
|
|
2017-12-22 22:21:38 +00:00
|
|
|
from tests.utils.constants import RESOURCE_PATH
|
|
|
|
|
|
|
|
TEST_PATH = RESOURCE_PATH / 'media'
|
2016-01-22 20:12:46 +00:00
|
|
|
TEST_MEDIA = [['avi_file.avi', 61495], ['mp3_file.mp3', 134426], ['mpg_file.mpg', 9404], ['mp4_file.mp4', 188336]]
|
|
|
|
|
2017-11-15 07:03:35 +00:00
|
|
|
|
2016-01-22 20:12:46 +00:00
|
|
|
class TestMediainfoWrapper(TestCase):
|
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_media_length(self):
|
2016-01-22 20:12:46 +00:00
|
|
|
"""
|
|
|
|
Test the Media Info basic functionality
|
|
|
|
"""
|
|
|
|
for test_data in TEST_MEDIA:
|
|
|
|
# GIVEN: a media file
|
2017-12-22 22:21:38 +00:00
|
|
|
full_path = str(TEST_PATH / test_data[0])
|
2016-01-22 20:12:46 +00:00
|
|
|
|
|
|
|
# WHEN the media data is retrieved
|
|
|
|
results = MediaInfoWrapper.parse(full_path)
|
|
|
|
|
|
|
|
# THEN you can determine the run time
|
2017-12-23 09:09:45 +00:00
|
|
|
assert results.tracks[0].duration == test_data[1], 'The correct duration is returned for ' + test_data[0]
|