Fix tests and linter errors, still need to handle todos
This commit is contained in:
@@ -14,7 +14,6 @@ from typing import (
|
||||
Tuple,
|
||||
)
|
||||
|
||||
from dataclasses_json import DataClassJsonMixin
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .api_objects import (
|
||||
|
@@ -548,12 +548,6 @@ class SublimeMusicApp(Gtk.Application):
|
||||
self.app_config.state.current_notification = None
|
||||
self.update_window()
|
||||
|
||||
# TODO
|
||||
def on_server_list_changed(self, action: Any, servers: GLib.Variant):
|
||||
assert 0
|
||||
self.app_config.providers = servers
|
||||
self.app_config.save()
|
||||
|
||||
def on_add_new_music_provider(self, *args):
|
||||
self.show_configure_servers_dialog()
|
||||
|
||||
@@ -561,6 +555,8 @@ class SublimeMusicApp(Gtk.Application):
|
||||
self.show_configure_servers_dialog(self.app_config.provider)
|
||||
|
||||
def on_switch_music_provider(self, _, provider_id: GLib.Variant):
|
||||
if self.app_config.state.playing:
|
||||
self.on_play_pause()
|
||||
self.app_config.save()
|
||||
self.app_config.current_provider_id = provider_id.get_string()
|
||||
self.reset_state()
|
||||
@@ -748,7 +744,7 @@ class SublimeMusicApp(Gtk.Application):
|
||||
self.loading_state = False
|
||||
|
||||
# Update the window according to the new server configuration.
|
||||
self.update_window(force=True)
|
||||
self.update_window()
|
||||
|
||||
def on_stack_change(self, stack: Gtk.Stack, _):
|
||||
self.app_config.state.current_tab = stack.get_visible_child_name()
|
||||
|
@@ -223,5 +223,4 @@ class AppConfiguration(DataClassJsonMixin):
|
||||
if state_filename := self._state_file_location:
|
||||
state_filename.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(state_filename, "wb+") as f:
|
||||
print("SAVE STATE", state_filename)
|
||||
pickle.dump(self.state, f)
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#current-downloads-list {
|
||||
min-height: 30px;
|
||||
min-width: 250px;
|
||||
min-width: 350px;
|
||||
}
|
||||
|
||||
#current-downloads-list-placeholder {
|
||||
|
@@ -108,7 +108,7 @@ class MainWindow(Gtk.ApplicationWindow):
|
||||
self.connect("button-release-event", self._on_button_release)
|
||||
|
||||
current_notification_hash = None
|
||||
current_other_providers: Tuple[Tuple[str, ProviderConfiguration], ...] = ()
|
||||
current_other_providers: Tuple[ProviderConfiguration, ...] = ()
|
||||
|
||||
def update(self, app_config: AppConfiguration, force: bool = False):
|
||||
notification = app_config.state.current_notification
|
||||
@@ -177,29 +177,21 @@ class MainWindow(Gtk.ApplicationWindow):
|
||||
|
||||
# Switch Provider options
|
||||
other_providers = tuple(
|
||||
filter(
|
||||
lambda kv: kv[0] != app_config.current_provider_id,
|
||||
app_config.providers.items(),
|
||||
)
|
||||
v
|
||||
for k, v in app_config.providers.items()
|
||||
if k != app_config.current_provider_id
|
||||
)
|
||||
if self.current_other_providers != other_providers:
|
||||
self.current_other_providers = other_providers
|
||||
for c in self.provider_options_box.get_children():
|
||||
self.provider_options_box.remove(c)
|
||||
|
||||
for key, provider in sorted(other_providers, key=lambda kv: kv[1].name):
|
||||
for provider in sorted(other_providers, key=lambda p: p.name.lower()):
|
||||
self.provider_options_box.pack_start(
|
||||
self._create_switch_provider_button(provider), False, True, 0,
|
||||
)
|
||||
|
||||
self.provider_options_box.show_all()
|
||||
# menu_items = [
|
||||
# ("Delete Cached Song Files", self._clear_song_file_cache),
|
||||
# ("Delete Cached Song Files and Metadata", self._clear_entire_cache),
|
||||
# ]
|
||||
# for text, clicked_fn in menu_items:
|
||||
# clear_song_cache = self._create_model_button(text, clicked_fn=clicked_fn)
|
||||
# switch_provider_options.pack_start(clear_song_cache, False, True, 0)
|
||||
|
||||
# Main Settings
|
||||
self.notification_switch.set_active(app_config.song_play_notification)
|
||||
|
@@ -12,7 +12,9 @@ from sublime.config import AppConfiguration, ProviderConfiguration
|
||||
@pytest.fixture
|
||||
def adapter_manager(tmp_path: Path):
|
||||
subsonic_config_store = ConfigurationStore(
|
||||
server_address="https://subsonic.example.com", username="test",
|
||||
server_address="https://subsonic.example.com",
|
||||
username="test",
|
||||
verify_cert=True,
|
||||
)
|
||||
subsonic_config_store.set_secret("password", "testpass")
|
||||
|
||||
|
@@ -20,7 +20,9 @@ MOCK_DATA_FILES = Path(__file__).parent.joinpath("mock_data")
|
||||
@pytest.fixture
|
||||
def adapter(tmp_path: Path):
|
||||
config = ConfigurationStore(
|
||||
server_address="https://subsonic.example.com", username="test",
|
||||
server_address="https://subsonic.example.com",
|
||||
username="test",
|
||||
verify_cert=True,
|
||||
)
|
||||
config.set_secret("password", "testpass")
|
||||
|
||||
@@ -73,6 +75,12 @@ def camel_to_snake(name: str) -> str:
|
||||
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", name).lower()
|
||||
|
||||
|
||||
def test_config_form():
|
||||
# Just make sure that the functions work. That's half of the battle.
|
||||
config_store = ConfigurationStore()
|
||||
SubsonicAdapter.get_configuration_form(config_store)
|
||||
|
||||
|
||||
def test_request_making_methods(adapter: SubsonicAdapter):
|
||||
expected = {
|
||||
"u": "test",
|
||||
|
Reference in New Issue
Block a user