From 3c6a6fb230678a071035c4301a245915b34ade31 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Fri, 15 Dec 2023 23:59:36 -0800 Subject: [PATCH] func tests --- src/ytdl_sub/script/script.py | 10 ---------- tests/unit/script/types/test_function.py | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/ytdl_sub/script/script.py b/src/ytdl_sub/script/script.py index 6b7f9e7c..c99d3b5d 100644 --- a/src/ytdl_sub/script/script.py +++ b/src/ytdl_sub/script/script.py @@ -455,13 +455,3 @@ class Script: return resolvable raise RuntimeException(f"Tried to get unresolved variable {variable_name}") - - @property - def variable_names(self) -> Set[str]: - """ - Returns - ------- - Set[str] - Names of all the variables within the Script. - """ - return set(list(self._variables.keys())) diff --git a/tests/unit/script/types/test_function.py b/tests/unit/script/types/test_function.py index 19d2e9d8..1331d485 100644 --- a/tests/unit/script/types/test_function.py +++ b/tests/unit/script/types/test_function.py @@ -47,12 +47,21 @@ class TestFunction: Script({"func": function_str}).resolve() @pytest.mark.parametrize( - "function_str", ["{%array_at({'a': 'dict?'}, 1)}" "{%array_extend('not', 'array')}"] + "function_str, expected_types, received_types", + [ + ("{%array_at({'a': 'dict?'}, 1)}", "Array, Integer", "Map, Integer"), + ("{%array_extend('not', 'array')}", "Array, ...", "String, String"), + ( + "{%replace('hi mom', 'mom', 'dad', 1, 0)}", + "String, String, String, Optional[Integer]", + "String, String, String, Integer, Integer", + ), + ], ) - def test_incompatible_types(self, function_str): + def test_incompatible_types(self, function_str: str, expected_types: str, received_types: str): with pytest.raises( IncompatibleFunctionArguments, - match=_incompatible_arguments_match(expected="Array, Integer", recieved="Map, Integer"), + match=_incompatible_arguments_match(expected=expected_types, recieved=received_types), ): Script({"func": function_str}).resolve()