A complete gutting of the internals of ytdl-sub to support functions in our variable syntax, in addition to being able to access a yt-dlp entry's .info.json fields using functions. Functionally, ytdl-sub should still look and behave the same from a user-perspective. With so many lines of code changed (+8927, -2708), no doubt there will be new issues. Please make a GH issue or reach out on Discord if your config/subscriptions break in any way/shape/form. Details on how to use function support will come soon in the form of proper documentation in our readthedocs.
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
import pytest
|
|
from unit.script.conftest import single_variable_output
|
|
|
|
from ytdl_sub.script.script import Script
|
|
|
|
|
|
class TestNumericFunctions:
|
|
@pytest.mark.parametrize(
|
|
"values, expected_output",
|
|
[
|
|
("'ow', 'lower'", []),
|
|
("'.*ow.*', 'lower'", ["lower"]),
|
|
("'.*(ow).*', 'lower'", ["lower", "ow"]),
|
|
("'(.*)(ow)(.*)', 'lower'", ["lower", "l", "ow", "er"]),
|
|
],
|
|
)
|
|
def test_regex_match(self, values: str, expected_output: str):
|
|
output = single_variable_output(f"{{%regex_match({values})}}")
|
|
assert output == expected_output
|
|
|
|
@pytest.mark.parametrize(
|
|
"values, expected_output",
|
|
[
|
|
("'ow', 'lower'", ["lower"]),
|
|
("'.*ow.*', 'lower'", ["lower"]),
|
|
("'.*(ow).*', 'lower'", ["lower", "ow"]),
|
|
("'(.*)(ow)(.*)', 'lower'", ["lower", "l", "ow", "er"]),
|
|
],
|
|
)
|
|
def test_regex_search(self, values: str, expected_output: str):
|
|
output = single_variable_output(f"{{%regex_search({values})}}")
|
|
assert output == expected_output
|
|
|
|
@pytest.mark.parametrize(
|
|
"values, expected_output",
|
|
[
|
|
("'ow', 'lower'", []),
|
|
("'.*ow.*', 'lower'", ["lower"]),
|
|
("'.*(ow).*', 'lower'", ["lower", "ow"]),
|
|
("'(.*)(ow)(.*)', 'lower'", ["lower", "l", "ow", "er"]),
|
|
],
|
|
)
|
|
def test_regex_fullmatch(self, values: str, expected_output: str):
|
|
output = single_variable_output(f"{{%regex_fullmatch({values})}}")
|
|
assert output == expected_output
|