fix: inherit .otag.toml from parent folders and use the file's own folder config
This commit is contained in:
parent
81d9d62db3
commit
042a60713a
4 changed files with 59 additions and 50 deletions
|
|
@ -144,7 +144,21 @@ def test_copy_tags_from_subfolder_to_folder(tree):
|
|||
|
||||
def test_config_without_tags(tree):
|
||||
(tree / orvani.CONFIG_FILE).write_text('plugins = ["pdf"]\n')
|
||||
assert OrvaniTag().CONFIG == {'plugins': ['pdf']}
|
||||
assert OrvaniTag().config('.') == {'plugins': ['pdf']}
|
||||
|
||||
|
||||
def test_subfolders_inherit_config(tree):
|
||||
(tree / orvani.CONFIG_FILE).write_text('plugins = ["pdf"]\n')
|
||||
(tree / 'sub' / 'deeper').mkdir()
|
||||
assert OrvaniTag().config('sub/deeper') == {'plugins': ['pdf']}
|
||||
|
||||
|
||||
def test_nearest_config_wins(tree):
|
||||
(tree / orvani.CONFIG_FILE).write_text('plugins = ["pdf"]\n')
|
||||
(tree / 'sub' / orvani.CONFIG_FILE).write_text('plugins = ["id3"]\n')
|
||||
o = OrvaniTag()
|
||||
assert o.config('sub') == {'plugins': ['id3']}
|
||||
assert o.config('.') == {'plugins': ['pdf']}
|
||||
|
||||
|
||||
def test_removing_last_entry_keeps_config(tree):
|
||||
|
|
|
|||
|
|
@ -120,3 +120,14 @@ def test_cmd_list_is_recursive_unless_no_recursive(cwd, monkeypatch, capsys):
|
|||
main()
|
||||
out = capsys.readouterr().out
|
||||
assert 'a.mp3' in out and 'deep.mp3' not in out
|
||||
|
||||
|
||||
def test_write_uses_config_of_the_files_folder(cwd):
|
||||
(cwd / 'sub').mkdir()
|
||||
(cwd / 'sub' / orvani.CONFIG_FILE).write_text('plugins = ["office"]\n')
|
||||
writer = PdfWriter()
|
||||
writer.add_blank_page(72, 72)
|
||||
writer.write(cwd / 'sub' / 'doc.pdf')
|
||||
|
||||
OrvaniTag().add('sub/doc.pdf', '#lofi')
|
||||
assert OrvaniTag().write_metadata('sub/doc.pdf', 'pdf') == [6, 'pdf']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue