Address TODOs in tests and make TODO check verify in test dir
This commit is contained in:
@@ -50,6 +50,9 @@ valid = True
|
|||||||
for path in Path("sublime").glob("**/*.py"):
|
for path in Path("sublime").glob("**/*.py"):
|
||||||
valid &= check_file(path)
|
valid &= check_file(path)
|
||||||
|
|
||||||
|
for path in Path("tests").glob("**/*.py"):
|
||||||
|
valid &= check_file(path)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Checks that the version in the CHANGELOG is the same as the version in ``__init__.py``.
|
Checks that the version in the CHANGELOG is the same as the version in ``__init__.py``.
|
||||||
"""
|
"""
|
||||||
|
@@ -206,10 +206,8 @@ class AppConfiguration(DataClassJsonMixin):
|
|||||||
if not (provider := self.provider):
|
if not (provider := self.provider):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
state_filename = Path(os.environ.get("XDG_DATA_HOME") or "~/.local/share")
|
assert self.cache_location
|
||||||
return state_filename.expanduser().joinpath(
|
return self.cache_location.joinpath(provider.id, "state.pickle")
|
||||||
"sublime-music", provider.id, "state.pickle"
|
|
||||||
)
|
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
# Save the config as YAML.
|
# Save the config as YAML.
|
||||||
|
@@ -127,7 +127,7 @@ def test_get_song_details(adapter_manager: AdapterManager):
|
|||||||
# song = AdapterManager.get_song_details("1")
|
# song = AdapterManager.get_song_details("1")
|
||||||
# print(song)
|
# print(song)
|
||||||
# assert 0
|
# assert 0
|
||||||
# TODO
|
# TODO (#180)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -178,18 +178,18 @@ def test_search_result_update():
|
|||||||
|
|
||||||
|
|
||||||
def test_search(adapter_manager: AdapterManager):
|
def test_search(adapter_manager: AdapterManager):
|
||||||
# TODO
|
# TODO (#180)
|
||||||
return
|
return
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
# TODO ingest data
|
# TODO (#180) ingest data
|
||||||
|
|
||||||
def search_callback(result: SearchResult):
|
def search_callback(result: SearchResult):
|
||||||
results.append((result.artists, result.albums, result.songs, result.playlists))
|
results.append((result.artists, result.albums, result.songs, result.playlists))
|
||||||
|
|
||||||
AdapterManager.search("ohea", search_callback=search_callback).result()
|
AdapterManager.search("ohea", search_callback=search_callback).result()
|
||||||
|
|
||||||
# TODO test getting results from the server and updating using that
|
# TODO (#180) test getting results from the server and updating using that
|
||||||
while len(results) < 1:
|
while len(results) < 1:
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|
||||||
|
@@ -178,12 +178,12 @@ def test_caching_get_playlists(cache_adapter: FilesystemAdapter):
|
|||||||
def test_no_caching_get_playlists(adapter: FilesystemAdapter):
|
def test_no_caching_get_playlists(adapter: FilesystemAdapter):
|
||||||
adapter.get_playlists()
|
adapter.get_playlists()
|
||||||
|
|
||||||
# TODO: Create a playlist (that should be allowed only if this is acting as
|
# TODO (#188): Create a playlist (that should be allowed only if this is acting as
|
||||||
# a ground truth adapter)
|
# a ground truth adapter)
|
||||||
# cache_adapter.create_playlist()
|
# cache_adapter.create_playlist()
|
||||||
|
|
||||||
adapter.get_playlists()
|
adapter.get_playlists()
|
||||||
# TODO: verify playlist
|
# TODO (#188): verify playlist
|
||||||
|
|
||||||
|
|
||||||
def test_caching_get_playlist_details(cache_adapter: FilesystemAdapter):
|
def test_caching_get_playlist_details(cache_adapter: FilesystemAdapter):
|
||||||
@@ -244,12 +244,12 @@ def test_no_caching_get_playlist_details(adapter: FilesystemAdapter):
|
|||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception):
|
||||||
adapter.get_playlist_details("1")
|
adapter.get_playlist_details("1")
|
||||||
|
|
||||||
# TODO: Create a playlist (that should be allowed only if this is acting as
|
# TODO (#188): Create a playlist (that should be allowed only if this is acting as
|
||||||
# a ground truth adapter)
|
# a ground truth adapter)
|
||||||
# cache_adapter.create_playlist()
|
# cache_adapter.create_playlist()
|
||||||
|
|
||||||
# adapter.get_playlist_details('1')
|
# adapter.get_playlist_details('1')
|
||||||
# TODO: verify playlist details
|
# TODO (#188): verify playlist details
|
||||||
|
|
||||||
|
|
||||||
def test_caching_get_playlist_then_details(cache_adapter: FilesystemAdapter):
|
def test_caching_get_playlist_then_details(cache_adapter: FilesystemAdapter):
|
||||||
|
@@ -24,10 +24,9 @@ def test_config_default_cache_location():
|
|||||||
assert config.cache_location == Path("~/.local/share/sublime-music").expanduser()
|
assert config.cache_location == Path("~/.local/share/sublime-music").expanduser()
|
||||||
|
|
||||||
|
|
||||||
def test_server_property():
|
def test_server_property(tmp_path: Path):
|
||||||
# TODO change the cache location so it doesn't clutter the
|
|
||||||
# ~/.local/share/sublime-music directory
|
|
||||||
config = AppConfiguration()
|
config = AppConfiguration()
|
||||||
|
config.cache_location = tmp_path
|
||||||
provider = ProviderConfiguration(
|
provider = ProviderConfiguration(
|
||||||
id="1",
|
id="1",
|
||||||
name="foo",
|
name="foo",
|
||||||
@@ -39,11 +38,7 @@ def test_server_property():
|
|||||||
config.current_provider_id = "1"
|
config.current_provider_id = "1"
|
||||||
assert config.provider == provider
|
assert config.provider == provider
|
||||||
|
|
||||||
expected_state_file_location = Path("~/.local/share").expanduser()
|
assert config._state_file_location == tmp_path.joinpath("1", "state.pickle",)
|
||||||
expected_state_file_location = expected_state_file_location.joinpath(
|
|
||||||
"sublime-music", "1", "state.pickle",
|
|
||||||
)
|
|
||||||
assert config._state_file_location == expected_state_file_location
|
|
||||||
|
|
||||||
|
|
||||||
def test_json_load_unload(config_filename: Path):
|
def test_json_load_unload(config_filename: Path):
|
||||||
|
@@ -13,6 +13,7 @@ def test_init():
|
|||||||
|
|
||||||
|
|
||||||
def is_close(expected: float, value: float, delta: float = 0.5) -> bool:
|
def is_close(expected: float, value: float, delta: float = 0.5) -> bool:
|
||||||
|
print(f"EXPECTED: {expected}, VALUE: {value}") # noqa: T001
|
||||||
return abs(value - expected) < delta
|
return abs(value - expected) < delta
|
||||||
|
|
||||||
|
|
||||||
@@ -59,10 +60,20 @@ def test_play():
|
|||||||
assert mpv_player.playing
|
assert mpv_player.playing
|
||||||
|
|
||||||
# Test seek
|
# Test seek
|
||||||
sleep(0.1)
|
for _ in range(5):
|
||||||
assert is_close(10, mpv_player.mpv.time_pos)
|
sleep(0.1)
|
||||||
|
if is_close(10, mpv_player.mpv.time_pos):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise Exception("Never was close")
|
||||||
mpv_player.seek(timedelta(seconds=20))
|
mpv_player.seek(timedelta(seconds=20))
|
||||||
assert is_close(20, mpv_player.mpv.time_pos)
|
|
||||||
|
for _ in range(5):
|
||||||
|
sleep(0.1)
|
||||||
|
if is_close(20, mpv_player.mpv.time_pos):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise Exception("Never was close")
|
||||||
|
|
||||||
# Pause so that it doesn't keep playing while testing
|
# Pause so that it doesn't keep playing while testing
|
||||||
mpv_player.pause()
|
mpv_player.pause()
|
||||||
|
Reference in New Issue
Block a user