forked from rc/aircox
mockup test files
This commit is contained in:
19
aircox/tests/controllers/test_diffusions.py
Normal file
19
aircox/tests/controllers/test_diffusions.py
Normal file
@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
|
||||
from aircox.controllers.diffusions import Diffusions
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def diffusions():
|
||||
return Diffusions
|
||||
|
||||
|
||||
class TestDiffusion:
|
||||
def test___init__(self):
|
||||
pass
|
||||
|
||||
def test_update(self):
|
||||
pass
|
||||
|
||||
def test_clean(self):
|
||||
pass
|
37
aircox/tests/controllers/test_log_archiver.py
Normal file
37
aircox/tests/controllers/test_log_archiver.py
Normal file
@ -0,0 +1,37 @@
|
||||
import pytest
|
||||
|
||||
from aircox.controllers.log_archiver import LogArchiver
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def log_archiver():
|
||||
return LogArchiver()
|
||||
|
||||
|
||||
class TestLogArchiver:
|
||||
def test_get_path(self):
|
||||
pass
|
||||
|
||||
def test_archive(self):
|
||||
pass
|
||||
|
||||
def test_archive_no_qs(self):
|
||||
pass
|
||||
|
||||
def test_archive_not_keep(self):
|
||||
pass
|
||||
|
||||
def test_sort_log(self):
|
||||
pass
|
||||
|
||||
def test_serialize(self):
|
||||
pass
|
||||
|
||||
def test_load(self):
|
||||
pass
|
||||
|
||||
def test_load_file_not_exists(self):
|
||||
pass
|
||||
|
||||
def test_get_relations(self):
|
||||
pass
|
22
aircox/tests/controllers/test_playlist_import.py
Normal file
22
aircox/tests/controllers/test_playlist_import.py
Normal file
@ -0,0 +1,22 @@
|
||||
import pytest
|
||||
|
||||
from aircox.controller.playlist_import import PlaylistImport
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def playlist_import():
|
||||
return PlaylistImport()
|
||||
|
||||
|
||||
class TestPlaylistImport:
|
||||
def test_reset(self):
|
||||
pass
|
||||
|
||||
def test_run(self):
|
||||
pass
|
||||
|
||||
def test_read(self):
|
||||
pass
|
||||
|
||||
def make_playlist(self):
|
||||
pass
|
111
aircox/tests/controllers/test_sound_file.py
Normal file
111
aircox/tests/controllers/test_sound_file.py
Normal file
@ -0,0 +1,111 @@
|
||||
import pytest
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
from django.conf import settings as conf
|
||||
from django.utils import timezone as tz
|
||||
|
||||
from aircox import models
|
||||
from aircox.controllers.sound_file import SoundFile
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def path_infos():
|
||||
return {
|
||||
"test/20220101_10h13_1_sample_1.mp3": {
|
||||
"year": 2022,
|
||||
"month": 1,
|
||||
"day": 1,
|
||||
"hour": 10,
|
||||
"minute": 13,
|
||||
"n": 1,
|
||||
"name": "Sample 1",
|
||||
},
|
||||
"test/20220102_10h13_sample_2.mp3": {
|
||||
"year": 2022,
|
||||
"month": 1,
|
||||
"day": 2,
|
||||
"hour": 10,
|
||||
"minute": 13,
|
||||
"name": "Sample 2",
|
||||
},
|
||||
"test/20220103_1_sample_3.mp3": {
|
||||
"year": 2022,
|
||||
"month": 1,
|
||||
"day": 3,
|
||||
"n": 1,
|
||||
"name": "Sample 3",
|
||||
},
|
||||
"test/20220104_sample_4.mp3": {
|
||||
"year": 2022,
|
||||
"month": 1,
|
||||
"day": 4,
|
||||
"name": "Sample 4",
|
||||
},
|
||||
"test/20220105.mp3": {
|
||||
"year": 2022,
|
||||
"month": 1,
|
||||
"day": 5,
|
||||
"name": "20220105",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sound_files(path_infos):
|
||||
return {
|
||||
k: r
|
||||
for k, r in (
|
||||
(path, SoundFile(conf.MEDIA_ROOT + "/" + path))
|
||||
for path in path_infos.keys()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
def test_sound_path(sound_files):
|
||||
for path, sound_file in sound_files.items():
|
||||
assert path == sound_file.sound_path
|
||||
|
||||
|
||||
def test_read_path(path_infos, sound_files):
|
||||
for path, sound_file in sound_files.items():
|
||||
expected = path_infos[path]
|
||||
result = sound_file.read_path(path)
|
||||
# remove None values
|
||||
result = {k: v for k, v in result.items() if v is not None}
|
||||
assert expected == result, "path: {}".format(path)
|
||||
|
||||
|
||||
def _setup_diff(program, info):
|
||||
episode = models.Episode(program=program, title="test-episode")
|
||||
at = tz.datetime(
|
||||
**{
|
||||
k: info[k]
|
||||
for k in ("year", "month", "day", "hour", "minute")
|
||||
if info.get(k)
|
||||
}
|
||||
)
|
||||
at = tz.make_aware(at)
|
||||
diff = models.Diffusion(
|
||||
episode=episode, start=at, end=at + timedelta(hours=1)
|
||||
)
|
||||
episode.save()
|
||||
diff.save()
|
||||
return diff
|
||||
|
||||
|
||||
@pytest.mark.django_db(transaction=True)
|
||||
def test_find_episode(sound_files):
|
||||
station = models.Station(name="test-station")
|
||||
program = models.Program(station=station, title="test")
|
||||
station.save()
|
||||
program.save()
|
||||
|
||||
for path, sound_file in sound_files.items():
|
||||
infos = sound_file.read_path(path)
|
||||
diff = _setup_diff(program, infos)
|
||||
sound = models.Sound(program=diff.program, file=path)
|
||||
result = sound_file.find_episode(sound, infos)
|
||||
assert diff.episode == result
|
||||
|
||||
# TODO: find_playlist, sync
|
@ -5,7 +5,7 @@ from django.utils import timezone as tz
|
||||
|
||||
from aircox.models import Sound
|
||||
from aircox.controllers import sound_monitor
|
||||
from aircox.test import Interface
|
||||
from aircox.test import Interface, interface
|
||||
|
||||
|
||||
now = tz.datetime.now()
|
||||
@ -21,7 +21,6 @@ def logger():
|
||||
logger = Interface(
|
||||
logging, {"info": None, "debug": None, "error": None, "warning": None}
|
||||
)
|
||||
print("logger", logger)
|
||||
return logger
|
||||
|
||||
|
||||
@ -73,7 +72,6 @@ class TestTask:
|
||||
def test_ping(self, task):
|
||||
task.timestamp = None
|
||||
task.ping()
|
||||
print("---", task.timestamp, now)
|
||||
assert task.timestamp >= now
|
||||
|
||||
@pytest.mark.django_db
|
||||
@ -124,13 +122,38 @@ class TestModifiedTask:
|
||||
|
||||
datetime._imeta.release()
|
||||
|
||||
def test__call__(self):
|
||||
pass
|
||||
def test__call__(self, modified_task, event):
|
||||
interface(modified_task, {"wait": None})
|
||||
modified_task(event)
|
||||
assert modified_task.calls["wait"]
|
||||
|
||||
|
||||
class TestMonitorHandler:
|
||||
pass
|
||||
def test_monitor___init__(self):
|
||||
pass
|
||||
|
||||
def test_on_created(self):
|
||||
pass
|
||||
|
||||
def test_on_deleted(self):
|
||||
pass
|
||||
|
||||
def test_on_moved(self):
|
||||
pass
|
||||
|
||||
def test_on_modified(self):
|
||||
pass
|
||||
|
||||
def test__submit(self):
|
||||
pass
|
||||
|
||||
|
||||
class SoundMonitor:
|
||||
pass
|
||||
def test_report(self):
|
||||
pass
|
||||
|
||||
def test_scan(self):
|
||||
pass
|
||||
|
||||
def test_monitor(self):
|
||||
pass
|
||||
|
47
aircox/tests/controllers/test_sound_stats.py
Normal file
47
aircox/tests/controllers/test_sound_stats.py
Normal file
@ -0,0 +1,47 @@
|
||||
import pytest
|
||||
|
||||
from aircox.controllers.sound_stats import SoxStats, SoundStats
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sox_stats():
|
||||
return SoxStats()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sound_stats():
|
||||
return SoundStats()
|
||||
|
||||
|
||||
class TestSoxStats:
|
||||
def test___init__(self):
|
||||
pass
|
||||
|
||||
def test_get(self):
|
||||
pass
|
||||
|
||||
def test_parse(self):
|
||||
pass
|
||||
|
||||
def test_analyse(self):
|
||||
pass
|
||||
|
||||
|
||||
class TestSoundStats:
|
||||
def test___init__(self):
|
||||
pass
|
||||
|
||||
def test_get_file_stats(self):
|
||||
pass
|
||||
|
||||
def test_analyze(self):
|
||||
pass
|
||||
|
||||
def test_analyze_no_sample_length(self):
|
||||
pass
|
||||
|
||||
def test_check(self):
|
||||
pass
|
||||
|
||||
def test_resume(self):
|
||||
pass
|
Reference in New Issue
Block a user