Skip to content
Snippets Groups Projects
Commit 5566e79d authored by David Trattnig's avatar David Trattnig
Browse files

test: add test cases for M3U spreading

parent 415a22cf
No related branches found
No related tags found
1 merge request!35ORM-less scheduling
#EXTM3U
#EXTINF:123,Alle - Unser Lied
/media/music-lib/Unser Album/Unser Lied.flac
#EXTINF:321,Alle - Dein Lied
music-lib/Unser Album/Dein Lied.ogg
#EXTINF:231,Alle - Liedlos
../music-lib/Alle/Unser Album/Liedlos.m4a
#EXTINF:213,Alle - Euer Lied
http://www.example.org/music/Alle-Unser_Album-Euer_Lied.mp3
\ No newline at end of file
#
# Aura Engine (https://gitlab.servus.at/aura/engine)
#
# Copyright (C) 2017-now() - The Aura Engine Team.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
import os
import unittest
from datetime import datetime, timedelta
from unittest import mock
from aura_engine.base.config import AuraConfig
from aura_engine.scheduling.domain import PlaylistItem
from aura_engine.scheduling.utils import M3UPlaylistProcessor
class TestSchedulingUtils(unittest.TestCase):
"""
Testing the scheduling utils.
"""
config = None
m3u = None
# Setup and teardown
def setUp(self):
self.config = AuraConfig()
self.m3u = M3UPlaylistProcessor()
self.m3u.playlist_folder = "./tests/m3u/"
def tearDown(self):
pass
#
# Test Cases
#
def test_spread_m3u_playlist(self):
print(self._testMethodName)
item = PlaylistItem("playlist://sample.m3u", None, 100, PlaylistItem.Metadata("", "", ""))
items = self.m3u.spread(item)
self.assertIsNotNone(items)
self.assertEqual(4, len(items))
self.assertEqual("file://music-lib/Unser Album/Dein Lied.ogg", items[1].source)
self.assertEqual("Alle", items[1].metadata.artist)
self.assertEqual("Dein Lied", items[1].metadata.title)
def test_spread_no_m3u_item(self):
print(self._testMethodName)
item = PlaylistItem("file://no-m3u.mp3", None, 100, PlaylistItem.Metadata("", "", ""))
items = self.m3u.spread(item)
self.assertIsNotNone(items)
self.assertEqual(1, len(items))
self.assertEqual("file://no-m3u.mp3", items[0].source)
def test_spread_no_m3u_playlist(self):
print(self._testMethodName)
print(self._testMethodName)
item = PlaylistItem("playlist://404.m3u", None, 100, PlaylistItem.Metadata("", "", ""))
items = self.m3u.spread(item)
self.assertEqual(0, len(items))
if __name__ == "__main__":
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment