mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
Extend and consolidate script
tests (#6663)
This commit is contained in:
parent
c69cdec052
commit
5ddad26476
8 changed files with 62 additions and 156 deletions
55
tests/components/script/common.yaml
Normal file
55
tests/components/script/common.yaml
Normal file
|
@ -0,0 +1,55 @@
|
|||
esphome:
|
||||
on_boot:
|
||||
then:
|
||||
- script.execute: my_script
|
||||
- script.execute:
|
||||
id: my_script_with_params
|
||||
prefix: "Test"
|
||||
param2: 0
|
||||
param3: true
|
||||
- script.wait: my_script
|
||||
- script.stop: my_script
|
||||
- if:
|
||||
condition:
|
||||
- script.is_running: my_script
|
||||
then:
|
||||
- logger.log: my_script is running
|
||||
|
||||
script:
|
||||
- id: my_script
|
||||
mode: single
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_queued
|
||||
mode: queued
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_parallel
|
||||
mode: parallel
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_restart
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_with_params
|
||||
parameters:
|
||||
prefix: string
|
||||
param2: uint8_t
|
||||
param3: bool
|
||||
then:
|
||||
- lambda: 'ESP_LOGD(prefix.c_str(), "Hello World! %u %u", param2, param3);'
|
||||
- if:
|
||||
condition:
|
||||
for:
|
||||
time: !lambda "return param2;"
|
||||
condition:
|
||||
script.is_running: my_script
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "API has stayed connected for at least %u minutes", param2);'
|
||||
- repeat:
|
||||
count: 5
|
||||
then:
|
||||
- logger.log: looping!
|
1
tests/components/script/test.bk72xx.yaml
Normal file
1
tests/components/script/test.bk72xx.yaml
Normal file
|
@ -0,0 +1 @@
|
|||
<<: !include common.yaml
|
|
@ -1,26 +1 @@
|
|||
script:
|
||||
- id: my_script
|
||||
mode: single
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_queued
|
||||
mode: queued
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_parallel
|
||||
mode: parallel
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_restart
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_with_params
|
||||
parameters:
|
||||
prefix: string
|
||||
param2: int
|
||||
param3: bool
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", (prefix + " Hello World!" + to_string(param2) + " " + to_string(param3)).c_str());'
|
||||
<<: !include common.yaml
|
||||
|
|
|
@ -1,26 +1 @@
|
|||
script:
|
||||
- id: my_script
|
||||
mode: single
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_queued
|
||||
mode: queued
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_parallel
|
||||
mode: parallel
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_restart
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_with_params
|
||||
parameters:
|
||||
prefix: string
|
||||
param2: int
|
||||
param3: bool
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", (prefix + " Hello World!" + to_string(param2) + " " + to_string(param3)).c_str());'
|
||||
<<: !include common.yaml
|
||||
|
|
|
@ -1,26 +1 @@
|
|||
script:
|
||||
- id: my_script
|
||||
mode: single
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_queued
|
||||
mode: queued
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_parallel
|
||||
mode: parallel
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_restart
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_with_params
|
||||
parameters:
|
||||
prefix: string
|
||||
param2: int
|
||||
param3: bool
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", (prefix + " Hello World!" + to_string(param2) + " " + to_string(param3)).c_str());'
|
||||
<<: !include common.yaml
|
||||
|
|
|
@ -1,26 +1 @@
|
|||
script:
|
||||
- id: my_script
|
||||
mode: single
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_queued
|
||||
mode: queued
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_parallel
|
||||
mode: parallel
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_restart
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_with_params
|
||||
parameters:
|
||||
prefix: string
|
||||
param2: int
|
||||
param3: bool
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", (prefix + " Hello World!" + to_string(param2) + " " + to_string(param3)).c_str());'
|
||||
<<: !include common.yaml
|
||||
|
|
|
@ -1,26 +1 @@
|
|||
script:
|
||||
- id: my_script
|
||||
mode: single
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_queued
|
||||
mode: queued
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_parallel
|
||||
mode: parallel
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_restart
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_with_params
|
||||
parameters:
|
||||
prefix: string
|
||||
param2: int
|
||||
param3: bool
|
||||
then:
|
||||
- lambda: 'ESP_LOGD(prefix.c_str(), "Hello World! %i %i", param2, param3);'
|
||||
<<: !include common.yaml
|
||||
|
|
|
@ -1,26 +1 @@
|
|||
script:
|
||||
- id: my_script
|
||||
mode: single
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_queued
|
||||
mode: queued
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_parallel
|
||||
mode: parallel
|
||||
max_runs: 2
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_restart
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "Hello World!");'
|
||||
- id: my_script_with_params
|
||||
parameters:
|
||||
prefix: string
|
||||
param2: int
|
||||
param3: bool
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", (prefix + " Hello World!" + to_string(param2) + " " + to_string(param3)).c_str());'
|
||||
<<: !include common.yaml
|
||||
|
|
Loading…
Reference in a new issue