ytdl-sub/tests/unit/utils/test_script_utils.py
Jesse Bannon e92b1cd12a
[BACKEND][HUGE] Function Support in variable syntax (#838)
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.
2023-12-18 16:08:15 -08:00

33 lines
999 B
Python

import copy
from unit.script.conftest import single_variable_output
from ytdl_sub.utils.script import ScriptUtils
class TestScriptUtils:
def test_dict_to_script(self):
json_dict = {
"string": "value",
"quotes": "has '' and \"\"",
"triple-single-quote": "right here! '''''''''''''''''''''''''''''' ack '''''''",
"int": 1,
"bool": True,
"list": [1, 2, 3],
"dict": {"a": 1, "b": 2},
"float": 3.14,
"nested_dict": {
"string": "value",
"int": 1,
"bool": True,
"list": [1, 2, 3],
"dict": {"a": 1, "b": 2},
"float": 3.14,
},
}
expected_output = copy.deepcopy(json_dict)
expected_output["triple-single-quote"] = "right here! ' ack '"
output = single_variable_output(ScriptUtils.to_script(json_dict))
assert output == expected_output