blob: 86580324fafedb6b8ea5c1a816b442d231048d85 (
plain)
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
|
import pytest
from json import loads
import pathlib
import shutil
from solo_tool.session_manager import loadSession, saveSession
from solo_tool.solo_tool import SoloTool
@pytest.fixture
def prepared_tmp_path(tmp_path):
testFiles = [
"test.flac",
"test.mp3",
"test_session.json"
]
for f in testFiles:
shutil.copy(pathlib.Path(f), tmp_path)
return tmp_path
def test_loadSession(prepared_tmp_path):
soloTool = loadSession(prepared_tmp_path / "test_session.json")
assert soloTool.songs == ["test.flac", "test.mp3"]
soloTool.song = 0
assert soloTool.keyPoints == []
soloTool.song = 1
assert soloTool.keyPoints == [0.1, 0.3]
def test_saveSession(prepared_tmp_path):
soloTool = SoloTool()
soloTool.addSong("test.flac")
soloTool.addSong("test.mp3")
soloTool.song = 1
soloTool.keyPoints = [0.1, 0.3]
testFile = prepared_tmp_path / "test_session_saved.json"
saveSession(soloTool, testFile)
with open(testFile, "r") as f:
savedSession = loads(f.read())
with open(prepared_tmp_path / "test_session.json", "r") as f:
testSession = loads(f.read())
assert savedSession == testSession
def test_loadAndSaveEmptySession(prepared_tmp_path):
emptyFile = prepared_tmp_path / "empty_session.json"
soloTool = SoloTool()
saveSession(soloTool, emptyFile)
reloadedTool = loadSession(emptyFile)
assert reloadedTool.songs == []
|