Added sorted() to python_script (#10621)

* added sorted() to python_script

* fixed lint errors
This commit is contained in:
Egor Tsinko 2017-11-16 23:06:02 -07:00 committed by Paulus Schoutsen
parent 24aeea5ca3
commit f052a0926b
2 changed files with 22 additions and 0 deletions

View file

@ -209,6 +209,27 @@ hass.states.set('hello.ab_list', '{}'.format(ab_list))
assert caplog.text == ''
@asyncio.coroutine
def test_execute_sorted(hass, caplog):
"""Test sorted() function."""
caplog.set_level(logging.ERROR)
source = """
a = sorted([3,1,2])
assert(a == [1,2,3])
hass.states.set('hello.a', a[0])
hass.states.set('hello.b', a[1])
hass.states.set('hello.c', a[2])
"""
hass.async_add_job(execute, hass, 'test.py', source, {})
yield from hass.async_block_till_done()
assert hass.states.is_state('hello.a', '1')
assert hass.states.is_state('hello.b', '2')
assert hass.states.is_state('hello.c', '3')
# No errors logged = good
assert caplog.text == ''
@asyncio.coroutine
def test_exposed_modules(hass, caplog):
"""Test datetime and time modules exposed."""