Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
infojunkie committed Nov 22, 2024
1 parent 2aaa7f9 commit 3ce5735
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "discogs-tag"
version = "1.3.0"
version = "1.3.1"
description = "An audio tagger based on Discogs metadata."
authors = ["infojunkie <[email protected]>"]
repository = "https://github.com/infojunkie/discogs-tag.py"
Expand Down
4 changes: 2 additions & 2 deletions src/discogs_tag/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,9 @@ def list_files(dir):
]))

def parse_options(options):
for skip in SKIP_KEYS:
options['skip_' + skip.lower()] = False
if 'skip' in options and options['skip'] is not None:
for skip in SKIP_KEYS:
options['skip_' + skip.lower()] = False
if isinstance(options['skip'], str):
options['skip'] = [options['skip']]
for skip in options['skip']:
Expand Down
75 changes: 75 additions & 0 deletions tests/test_discogs_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,81 @@ def test_apply_metadata_track():
assert audio['title'] == 'Title: Sub track 1 / Sub track 2'
assert audio['tracknumber'] == '2'

def test_skip_only_options():
audio = apply_metadata_track({
'year': 2002,
'artists': [{
'anv': 'Artist 1'
}, {
'name': 'Artist 2'
}, {
'anv': '',
'name': 'Artist 3 (56)'
}],
}, {
'title': 'Title',
'position': '',
'sub_tracks': [{
'type_': 'track',
"title": "Sub track 1",
}, {
'type_': 'track',
'title': 'Sub track 2',
}, {
'type_': 'data',
'title': "Not a track",
}],
'extraartists': [{
'role': 'Guitar',
'name': 'Guitarist'
}, {
'role': 'Written-By',
'name': 'Composer 1'
}, {
'role': 'Composed By',
'name': 'Composer 2'
}]
}, { 'title': 'Some other title' }, 2, parse_options({ 'skip': ['title'] }))
assert audio['title'] == 'Some other title'
assert audio['tracknumber'] == '2'

audio = apply_metadata_track({
'year': 2002,
'artists': [{
'anv': 'Artist 1'
}, {
'name': 'Artist 2'
}, {
'anv': '',
'name': 'Artist 3 (56)'
}],
}, {
'title': 'Title',
'position': '',
'sub_tracks': [{
'type_': 'track',
"title": "Sub track 1",
}, {
'type_': 'track',
'title': 'Sub track 2',
}, {
'type_': 'data',
'title': "Not a track",
}],
'extraartists': [{
'role': 'Guitar',
'name': 'Guitarist'
}, {
'role': 'Written-By',
'name': 'Composer 1'
}, {
'role': 'Composed By',
'name': 'Composer 2'
}]
}, { 'title': 'Some other title' }, 2, parse_options({ 'only': ['title'] }))
assert audio['title'] == 'Title: Sub track 1 / Sub track 2'
assert 'tracknumber' not in audio

def test_apply_metadata():
with open('tests/18051880.json') as release:
data = json.load(release)
Expand Down

0 comments on commit 3ce5735

Please sign in to comment.