Commit 3e950274 authored by David Trattnig's avatar David Trattnig
Browse files

Some basic test case. #63

parent a19f0338
......@@ -26,11 +26,9 @@ from datetime import datetime
from src.base.logger import AuraLogger
from src.base.config import AuraConfig
from src.scheduling.models import Timeslot
# src
from src.scheduling.scheduler import AuraScheduler
class TestLogger(unittest.TestCase):
aura_logger = None
......@@ -44,117 +42,41 @@ class TestLogger(unittest.TestCase):
class TestConfig(unittest.TestCase):
aura_config = None
config = None
def setUp(self):
self.aura_config = AuraConfig()
self.config = AuraConfig()
def test_config(self):
# is ini path correct set?
self.assertEqual(self.config.ini_path, "/etc/aura/engine.ini")
# Check if config is available
self.assertIsNotNone(self.config.ini_path)
# install_dir is set by runtime. is it a directory?
# Check if "install_dir" is a valid directory (is evaluated at runtime)
self.assertTrue(os.path.isdir(self.config.get("install_dir")))
# calendarurl and importerurl set and valid urls?
self.assertTrue(validators.url(self.config.get("calendarurl")))
self.assertTrue(validators.url(self.config.get("importerurl")))
# is liquidsoap socketdir set and a directory?
# 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 "socketdir" is set and a directory
self.assertTrue(os.path.isdir(self.config.get("socketdir")))
# database settings set?
# 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"))
class TestTimeslot(unittest.TestCase):
timeslot = None
def setUp(self):
self.timeslot = Timeslot()
def test_timeslot(self):
# select one and check if its not None and a Timeslot
entry = self.timeslot.select_by_id(1)
self.assertIsNotNone(entry)
self.assertIsInstance(entry, Timeslot)
class TestTimeslotEntry(unittest.TestCase):
timeslot_entry = None
def setUp(self):
self.timeslot_entry = TimeslotEntry()
def test_timeslot_entry(self):
# select one playlist and check if its not None, a TimeslotEntry
entry = self.timeslot_entry.select_playlist(2)
self.assertIsNotNone(entry)
self.assertIsInstance(entry, list)
self.assertGreaterEqual(len(entry), 1)
class TestTrackService(unittest.TestCase):
track_service = None
def setUp(self):
self.track_service = TrackService()
def test_track_service(self):
day = datetime.strptime("19.03.2018", "%d.%m.%Y")
entry = self.track_service.select_by_day(day)
self.assertIsNotNone(entry)
self.assertIsInstance(entry, list)
class TestAuraUser(unittest.TestCase):
aura_user = None
def setUp(self):
self.aura_user = AuraUser()
def test_add_user(self):
username = "user"
password = "password"
role = "admin"
login_cnt = len(self.aura_user.getLogins())
# insert user
key = self.aura_user.insertUser(username, password, role)
self.assertGreaterEqual(len(self.aura_user.getLogins()), login_cnt)
# selecting user and check data
user = self.aura_user.getUserByKey(key)
self.assertEqual(user["username"], username)
# TODO: no encrypted storage.., but usermgm not really in use
self.assertEqual(user["password"], password)
self.assertEqual(user["role"], role)
class TestLQSComm(unittest.TestCase):
comm = None
def setUp(self):
# wosn do passiert?
p = AuraConfig().config
self.soundsystem = SoundSystem(p)
self.soundsystem.scheduler = AuraScheduler(p)
self.soundsystem.init_player()
def test_get_active_channel(self):
active_channel = self.comm.get_active_channel()
print(active_channel)
if __name__ == '__main__':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment