Fix lints in tests (#682)

* Fix lints on tests

* Formatting

* Formatting
This commit is contained in:
Nathan Thomas 2024-05-14 16:27:41 -07:00 committed by GitHub
parent 178168cc68
commit 54d05e1330
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 50 additions and 50 deletions

View file

@ -124,10 +124,14 @@ class Converter:
aformat = []
if isinstance(self.sampling_rate, int):
sample_rates = "|".join(str(rate) for rate in SAMPLING_RATES if rate <= self.sampling_rate)
sample_rates = "|".join(
str(rate) for rate in SAMPLING_RATES if rate <= self.sampling_rate
)
aformat.append(f"sample_rates={sample_rates}")
elif self.sampling_rate is not None:
raise TypeError(f"Sampling rate must be int, not {type(self.sampling_rate)}")
raise TypeError(
f"Sampling rate must be int, not {type(self.sampling_rate)}"
)
if isinstance(self.bit_depth, int):
bit_depths = ["s16p", "s16"]
@ -143,9 +147,9 @@ class Converter:
raise TypeError(f"Bit depth must be int, not {type(self.bit_depth)}")
if aformat:
aformat_params = ':'.join(aformat)
aformat_params = ":".join(aformat)
command.extend(["-af", f"aformat={aformat_params}"])
# automatically overwrite
command.extend(["-y", self.tempfile])

View file

@ -1,4 +1,5 @@
"""Manages the information that will be embeded in the audio file."""
from . import util
from .album import AlbumInfo, AlbumMetadata
from .artist import ArtistMetadata

View file

@ -4,8 +4,8 @@ import os
import pytest
from util import arun
from streamrip.config import Config
from streamrip.client.qobuz import QobuzClient
from streamrip.config import Config
@pytest.fixture(scope="session")

View file

@ -9,9 +9,9 @@ def arun(coro):
def afor(async_gen):
async def _afor(async_gen):
l = []
item = []
async for item in async_gen:
l.append(item)
return l
item.append(item)
return item
return arun(_afor(async_gen))

View file

@ -4,8 +4,28 @@ import shutil
import pytest
import tomlkit
from streamrip.config import *
from streamrip.config import _get_dict_keys_r, _nested_set
from streamrip.config import (
ArtworkConfig,
CliConfig,
Config,
ConfigData,
ConversionConfig,
DatabaseConfig,
DeezerConfig,
DownloadsConfig,
FilepathsConfig,
LastFmConfig,
MetadataConfig,
MiscConfig,
QobuzConfig,
QobuzDiscographyFilterConfig,
SoundcloudConfig,
TidalConfig,
YoutubeConfig,
_get_dict_keys_r,
_nested_set,
update_config,
)
SAMPLE_CONFIG = "tests/test_config.toml"
OLD_CONFIG = "tests/test_config_old.toml"
@ -242,15 +262,6 @@ def test_sample_config_data_fields(sample_config_data):
assert sample_config_data.conversion == test_config.conversion
# def test_config_save_file_called_on_del(sample_config, mocker):
# sample_config.file.set_modified()
# mockf = mocker.Mock()
#
# sample_config.save_file = mockf
# sample_config.__del__()
# mockf.assert_called_once()
def test_config_update_on_save():
tmp_config_path = "tests/config2.toml"
shutil.copy(SAMPLE_CONFIG, tmp_config_path)
@ -264,19 +275,6 @@ def test_config_update_on_save():
assert conf2.session.downloads.folder == "new_folder"
# def test_config_update_on_del():
# tmp_config_path = "tests/config2.toml"
# shutil.copy(SAMPLE_CONFIG, tmp_config_path)
# conf = Config(tmp_config_path)
# conf.file.downloads.folder = "new_folder"
# conf.file.set_modified()
# del conf
# conf2 = Config(tmp_config_path)
# os.remove(tmp_config_path)
#
# assert conf2.session.downloads.folder == "new_folder"
def test_config_dont_update_without_set_modified():
tmp_config_path = "tests/config2.toml"
shutil.copy(SAMPLE_CONFIG, tmp_config_path)

View file

@ -1,7 +1,8 @@
import pytest
import tomlkit
from tomlkit.toml_document import TOMLDocument
from streamrip.config import *
from streamrip.config import ConfigData
@pytest.fixture()

View file

@ -1,6 +1,6 @@
import json
from streamrip.metadata import *
from streamrip.metadata import AlbumMetadata, TrackMetadata
with open("tests/qobuz_album_resp.json") as f:
qobuz_album_resp = json.load(f)
@ -16,7 +16,7 @@ def test_album_metadata_qobuz():
assert info.quality == 3
assert info.container == "FLAC"
assert info.label == "Rhino - Warner Records"
assert info.explicit == False
assert info.explicit is False
assert info.sampling_rate == 96
assert info.bit_depth == 24
assert info.booklets is None

View file

@ -5,7 +5,14 @@ import pytest
from mutagen.flac import FLAC
from util import arun
from streamrip.metadata import *
from streamrip.metadata import (
AlbumInfo,
AlbumMetadata,
Covers,
TrackInfo,
TrackMetadata,
tag_file,
)
TEST_FLAC_ORIGINAL = "tests/silence.flac"
TEST_FLAC_COPY = "tests/silence_copy.flac"

View file

@ -25,19 +25,8 @@ def test_pending_resolve(qobuz_client: QobuzClient):
dir = "tests/tests/Fleetwood Mac - Rumours (1977) [FLAC] [24B-96kHz]"
assert os.path.isdir(dir)
assert os.path.isfile(os.path.join(dir, "cover.jpg"))
# embedded_cover_path aka t.cover_path is
# ./tests/./tests/Fleetwood Mac - Rumours (1977) [FLAC] [24B-96kHz]/
# __artwork/cover-9202762427033526105.jpg
assert os.path.isfile(t.cover_path)
assert isinstance(t, Track)
assert isinstance(t.downloadable, Downloadable)
assert t.cover_path is not None
shutil.rmtree(dir)
# def test_pending_resolve_mp3(qobuz_client: QobuzClient):
# qobuz_client.config.session.qobuz.quality = 1
# p = PendingSingle("19512574", qobuz_client, qobuz_client.config)
# t = arun(p.resolve())
# assert isinstance(t, Track)
# assert False

View file

@ -9,9 +9,9 @@ def arun(coro):
def afor(async_gen):
async def _afor(async_gen):
l = []
items = []
async for item in async_gen:
l.append(item)
return l
items.append(item)
return items
return arun(_afor(async_gen))