Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
geigerzaehler committed Apr 1, 2024
1 parent 5858ad4 commit e979890
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
22 changes: 4 additions & 18 deletions test/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from beets.ui import UserError
from beets.util import bytestring_path, syspath
from confuse import ConfigValueError
from helper import TestHelper, control_stdin
from helper import TestHelper, control_stdin, convert_command
from mediafile import MediaFile
from typeguard import check_type

Expand All @@ -22,12 +22,7 @@ def test_external(self):
external_dir = os.path.join(self.mkdtemp(), "myplayer")
self.config["convert"]["formats"] = {
"aac": {
"command": (
'powershell -Command "'
"Copy-Item -Path '$source' -Destination '$dest';"
"Add-Content -Path '$dest' -Value ISAAC"
'"'
),
"command": convert_command("ISAAC"),
"extension": "m4a",
},
}
Expand Down Expand Up @@ -470,14 +465,7 @@ class ExternalConvertTest(TestHelper):
def setUp(self):
super().setUp()
external_dir = self.mkdtemp()
self.config["convert"]["formats"] = {
"ogg": (
'powershell -Command "'
"Copy-Item -Path '$source' -Destination '$dest';"
"Add-Content -Path '$dest' -Value ISOGG"
'"'
)
}
self.config["convert"]["formats"] = {"ogg": convert_command("ISOGG")}
self.config["alternatives"] = {
"myexternal": {
"directory": external_dir,
Expand Down Expand Up @@ -542,9 +530,7 @@ def test_no_move_on_extension_change(self):
item = self.add_track(myexternal="true", format="m4a")
self.runcli("alt", "update", "myexternal")

self.config["convert"]["formats"] = {
"mp3": "bash -c \"cp '$source' '$dest';" + "printf ISMP3 >> '$dest'\""
}
self.config["convert"]["formats"] = {"mp3": convert_command("MP3")}
self.config["alternatives"]["myexternal"]["formats"] = "mp3"

# Assert that this re-encodes instead of copying the ogg file
Expand Down
16 changes: 16 additions & 0 deletions test/helper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import platform
import shutil
import sys
import tempfile
Expand Down Expand Up @@ -324,3 +325,18 @@ def submit(self, *args, **kwargs):

def shutdown(self, wait=True):
pass


def convert_command(tag: str) -> str:
match platform.system():
case "Windows":
return (
'powershell -Command "'
"Copy-Item -Path '$source' -Destination '$dest' -NoNewline;"
f"Add-Content -Path '$dest' -Value {tag}"
'"'
)
case "Linux":
return f"bash -c\" cp '$source' '$dest'; printf {tag} >> '$dest' \""
case system:
raise Exception(f"Unsupported system: {system}")

0 comments on commit e979890

Please sign in to comment.