File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ from custom_components .python_script import execute_script
2+
3+ hass = type ("" , (), {})
4+ logger = type ("" , (), {})
5+
6+
7+ def test_issue6 ():
8+ # https://github.com/AlexxIT/PythonScriptsPro/issues/6
9+ source = """def foobar():
10+ pass
11+ foobar()
12+ (lambda: foobar())()
13+ out = 123
14+ """
15+ code = compile (source , "<string>" , "exec" )
16+ result = execute_script (hass , {}, logger , code )
17+ assert result == {"out" : 123 }
18+
19+
20+ def test_issue18 ():
21+ # https://github.com/AlexxIT/PythonScriptsPro/issues/18
22+ source = """import requests
23+ def foobar():
24+ from requests import session
25+ out = 123
26+ """
27+ code = compile (source , "<string>" , "exec" )
28+ result = execute_script (hass , {}, logger , code )
29+ assert result == {"out" : 123 }
30+
31+
32+ def test_issue23 ():
33+ # https://github.com/AlexxIT/PythonScriptsPro/issues/23
34+ source = """from .secrets import get_secret
35+ out = 123
36+ """
37+ code = compile (source , "<string>" , "exec" )
38+ result = execute_script (hass , {}, logger , code )
39+ assert result == {
40+ "error" : "No module named 'custom_components.python_script.secrets'"
41+ }
You can’t perform that action at this time.
0 commit comments