Skip to content

Commit

Permalink
add podcast sorting test
Browse files Browse the repository at this point in the history
  • Loading branch information
tfeldmann committed Apr 4, 2024
1 parent 5e300d1 commit b858f04
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/filters/test_regex.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path

import pytest
from conftest import make_files
from conftest import make_files, read_files
from pyfakefs.fake_filesystem import FakeFilesystem

from organize import Config
Expand Down Expand Up @@ -60,3 +60,31 @@ def test_multiple_regex_placeholders(fs: FakeFilesystem):
out = Path("/test/out.txt").read_text()
assert "test 123 test-123 jpg" in out
assert "other 456 other-456 pdf" in out


def test_podcast_sorting(fs: FakeFilesystem):
make_files(
[
"My Podcast Ep 1.mp3",
"My Podcast Ep 2.mp3",
"My Podcast Ep 3.mp3",
"Your Podcast Ep 1.mp3",
"Your Podcast Ep 2.mp3",
"Your Podcast Ep 3.mp3",
],
"test",
)

config = r"""
rules:
- locations: /test/
filters:
- regex: '^(?P<podcast>.+?) (?P<episode>Ep \d+\.mp3)'
actions:
- move: '/test/{regex.podcast}/{regex.episode}'
"""
Config.from_string(config).execute(simulate=False)
assert read_files("test") == {
"My Podcast": {"Ep 1.mp3": "", "Ep 2.mp3": "", "Ep 3.mp3": ""},
"Your Podcast": {"Ep 1.mp3": "", "Ep 2.mp3": "", "Ep 3.mp3": ""},
}

0 comments on commit b858f04

Please sign in to comment.