test_config.py 2.55 KB
Newer Older
David Trattnig's avatar
David Trattnig committed
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
65
66
67
68
69
70
71
72
73

#
# 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 src.base.utils import SimpleUtil as SU
from src.base.config import AuraConfig




class TestConfig(unittest.TestCase):
    """
    Testing the Configuration.
    """
    config = None

    def setUp(self):
        self.config = AuraConfig()


    def test_config(self):
        # Check if config is available
        self.assertIsNotNone(self.config.ini_path)

        # Check if "install_dir" is a valid directory (is evaluated at runtime)
        self.assertTrue(os.path.isdir(self.config.get("install_dir")))

        # Check API Urls
        self.assertTrue(validators.url(self.config.get("api_steering_status")))
        self.assertTrue(validators.url(self.config.get("api_steering_calendar")))
        self.assertTrue(validators.url(self.config.get("api_tank_status")))
        tank_playlist_url = self.config.get("api_tank_playlist").replace("${ID}", "1")
        self.assertTrue(validators.url(tank_playlist_url))
        self.assertTrue(validators.url(self.config.get("api_engine_status")))
        self.assertTrue(validators.url(self.config.get("api_engine_store_playlog")))
        self.assertTrue(validators.url(self.config.get("api_engine_store_clock")))
        engine_health_url = self.config.get("api_engine_store_health").replace("${ENGINE_NUMBER}", "1")
        self.assertTrue(validators.url(engine_health_url))

        # Check if Liquidsoap "socket_dir" is set and a directory
        self.assertTrue(os.path.isdir(self.config.get("socket_dir")))

        # Check if database settings are set
        self.assertIsNotNone(self.config.get("db_user"))
        self.assertIsNotNone(self.config.get("db_pass"))
        self.assertIsNotNone(self.config.get("db_name"))
        self.assertIsNotNone(self.config.get("db_host"))




if __name__ == '__main__':
    unittest.main()