Fixed some tests

This commit is contained in:
Sumner Evans
2020-04-06 09:05:52 -06:00
parent a695be3340
commit a6066da532
2 changed files with 16 additions and 10 deletions

View File

@@ -61,6 +61,9 @@ class UIState:
active_playlist_id: Optional[str] = None
def migrate(self):
pass
@property
def current_song(self) -> Optional[Child]:
if (not self.play_queue or self.current_song_index < 0

View File

@@ -1,5 +1,6 @@
import os
from dataclasses import asdict
from pathlib import Path
import yaml
@@ -16,25 +17,27 @@ def test_config_default_cache_location():
def test_server_property():
config = AppConfiguration()
server = ServerConfiguration(
name='Test',
server_address='https://test.host',
username='test',
)
name='foo', server_address='bar', username='baz')
config.servers.append(server)
assert config.server is None
config.current_server = 0
config.current_server_index = 0
assert asdict(config.server) == asdict(server)
expected_state_file_location = Path('~/.local/share').expanduser()
expected_state_file_location = expected_state_file_location.joinpath(
'sublime-music',
'6df23dc03f9b54cc38a0fc1483df6e21',
'state.pickle',
)
assert config.state_file_location == expected_state_file_location
def test_yaml_load_unload():
config = AppConfiguration()
server = ServerConfiguration(
name='Test',
server_address='https://test.host',
username='test',
)
name='foo', server_address='bar', username='baz')
config.servers.append(server)
config.current_server = 0
config.current_server_index = 0
yamlified = yaml.dump(asdict(config))
unyamlified = yaml.load(yamlified, Loader=yaml.CLoader)