diff --git a/tests/test_engine_resources.py b/tests/test_engine_resources.py new file mode 100644 index 0000000000000000000000000000000000000000..77e16fc8f5f9e964c2cc7597ade6c4cc9463e1c6 --- /dev/null +++ b/tests/test_engine_resources.py @@ -0,0 +1,77 @@ +# +# 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 os +import unittest + +import validators + +from aura_engine.base.config import AuraConfig +from aura_engine.core.channels import ChannelName, ChannelType +from aura_engine.resources import ResourceMapping, ResourceType + + +class TestEngineResources(unittest.TestCase): + """ + Testing the engine resource utilities. + """ + + config = None + + def setUp(self): + self.config = AuraConfig() + + def test_resource_mapping(self): + print(self._testMethodName) + + rm = ResourceMapping() + ct = rm.type_for_resource(ResourceType.FILE) + self.assertEqual(ChannelType.QUEUE, ct) + ct = rm.type_for_resource(ResourceType.STREAM_HTTP) + self.assertEqual(ChannelType.HTTP, ct) + ct = rm.type_for_resource(ResourceType.LINE) + self.assertEqual(ChannelType.LIVE, ct) + ct = rm.type_for_resource(ResourceType.PLAYLIST) + self.assertEqual(ChannelType.QUEUE, ct) + ct = rm.type_for_resource(ResourceType.POOL) + self.assertEqual(ChannelType.QUEUE, ct) + + def test_live_channel_for_resource(self): + print(self._testMethodName) + + rm = ResourceMapping() + live_channel: ChannelName = rm.live_channel_for_resource("line://0") + self.assertEqual("LIVE_0", live_channel.name) + self.assertEqual("in_line_0", live_channel.value) + live_channel: ChannelName = rm.live_channel_for_resource("line://1") + self.assertEqual("LIVE_1", live_channel.name) + self.assertEqual("in_line_1", live_channel.value) + live_channel: ChannelName = rm.live_channel_for_resource("line://2") + self.assertEqual("LIVE_2", live_channel.name) + self.assertEqual("in_line_2", live_channel.value) + live_channel: ChannelName = rm.live_channel_for_resource("line://3") + self.assertEqual("LIVE_3", live_channel.name) + self.assertEqual("in_line_3", live_channel.value) + live_channel: ChannelName = rm.live_channel_for_resource("line://4") + self.assertEqual("LIVE_4", live_channel.name) + self.assertEqual("in_line_4", live_channel.value) + + +if __name__ == "__main__": + unittest.main()