Skip to content

Commit 0da0bcc

Browse files
committed
chore: Json vars update
1 parent eb5e42f commit 0da0bcc

7 files changed

Lines changed: 62 additions & 4 deletions

File tree

.github/scripts/sync-examples.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ build_codespaces_badge() {
4747
local has_devcontainer="$2" # "true" or "false"
4848
if [[ "${has_devcontainer}" == "true" ]]; then
4949
printf '[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=%s)\n' "${repo_id}"
50+
else
51+
echo "No .devcontainer found — skipping Codespaces badge."
5052
fi
5153
}
5254

@@ -144,6 +146,8 @@ sync_example() {
144146
if [[ -f "${tmpdir}/README.md" ]]; then
145147
prepend_header "${tmpdir}/README.md" "$(build_header "${name}" "${repo_id}" "${has_devcontainer}")"
146148
append_footer "${tmpdir}/README.md" "$(build_footer "${repo_id}" "${has_devcontainer}")"
149+
else
150+
echo " ❌ No README.md found — skipping header/footer injection."
147151
fi
148152

149153
# Commit and push if anything changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"cookbook": {
3+
"pasta": {
4+
"name": "Spaghetti Carbonara",
5+
"servings": 2,
6+
"time_minutes": 20,
7+
"ingredients": ["spaghetti", "eggs", "pancetta", "pecorino", "black pepper"]
8+
},
9+
"soup": {
10+
"name": "Tomato Basil Soup",
11+
"servings": 4,
12+
"time_minutes": 35,
13+
"ingredients": ["tomatoes", "basil", "onion", "garlic", "cream"]
14+
},
15+
"dessert": {
16+
"name": "Tiramisu",
17+
"servings": 6,
18+
"time_minutes": 30,
19+
"ingredients": ["mascarpone", "espresso", "ladyfingers", "eggs", "cocoa"]
20+
}
21+
}
22+
}

_dev/_examples/rf-python-varfiles/template/Data/pyvars-simple.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import random
33
import time
44

5-
USER = os.getlogin() # current login name
65
RANDOM_INT = random.randint(0, 10) # random integer in range [0,10]
76
CURRENT_TIME = time.asctime() # timestamp like 'Thu Apr 6 12:45:21 2006'
87
if time.localtime()[3] > 12:

_dev/_examples/rf-python-varfiles/template/suite.robot

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Variables Data/pyvars-simple.py
44
Variables Data/pyvars-nested.py
55
Variables Data/pyvars-getvariables.py ${BROWSER}
66
Variables Data/ymlvars-nested.yaml
7+
Variables Data/jsonvars-nested.json
78

89
*** Variables ***
910

@@ -14,7 +15,6 @@ ${BROWSER} chrome
1415

1516
Test Pyvars-Simple
1617
[Documentation] How to expose simple scalar values from a Python file as suite variables.
17-
Log Username = ${USER}
1818
Log Random Number = ${RANDOM_INT}
1919
Log Current time is ${CURRENT_TIME}
2020
Log Is it afternoon? ${AFTERNOON}.
@@ -34,6 +34,12 @@ Test YML-Nested
3434
Should Be Equal ${cfg}[${ENV}][user] dev_user
3535
Should Be Equal ${cfg}[${ENV}][password] dev_password
3636

37+
Test JSON-Nested
38+
[Documentation] How to load a nested data structure from a YAML variable file — same access syntax as Python dicts.
39+
Should Be Equal ${cookbook}[pasta][name] Spaghetti Carbonara
40+
Should Be Equal As Integers ${cookbook}[pasta][time_minutes] 20
41+
Should Contain ${cookbook}[dessert][ingredients] mascarpone
42+
3743
Test Get-Variables With Argument
3844
[Documentation] How to use a get_variables() function to return different variable sets based on an argument passed at import time.
3945
Should Be Equal ${BROWSER} chrome
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"cookbook": {
3+
"pasta": {
4+
"name": "Spaghetti Carbonara",
5+
"servings": 2,
6+
"time_minutes": 20,
7+
"ingredients": ["spaghetti", "eggs", "pancetta", "pecorino", "black pepper"]
8+
},
9+
"soup": {
10+
"name": "Tomato Basil Soup",
11+
"servings": 4,
12+
"time_minutes": 35,
13+
"ingredients": ["tomatoes", "basil", "onion", "garlic", "cream"]
14+
},
15+
"dessert": {
16+
"name": "Tiramisu",
17+
"servings": 6,
18+
"time_minutes": 30,
19+
"ingredients": ["mascarpone", "espresso", "ladyfingers", "eggs", "cocoa"]
20+
}
21+
}
22+
}

examples/rf-python-varfiles/Data/pyvars-simple.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import random
33
import time
44

5-
USER = os.getlogin() # current login name
65
RANDOM_INT = random.randint(0, 10) # random integer in range [0,10]
76
CURRENT_TIME = time.asctime() # timestamp like 'Thu Apr 6 12:45:21 2006'
87
if time.localtime()[3] > 12:

examples/rf-python-varfiles/suite.robot

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Variables Data/pyvars-simple.py
44
Variables Data/pyvars-nested.py
55
Variables Data/pyvars-getvariables.py ${BROWSER}
66
Variables Data/ymlvars-nested.yaml
7+
Variables Data/jsonvars-nested.json
78

89
*** Variables ***
910

@@ -14,7 +15,6 @@ ${BROWSER} chrome
1415

1516
Test Pyvars-Simple
1617
[Documentation] How to expose simple scalar values from a Python file as suite variables.
17-
Log Username = ${USER}
1818
Log Random Number = ${RANDOM_INT}
1919
Log Current time is ${CURRENT_TIME}
2020
Log Is it afternoon? ${AFTERNOON}.
@@ -34,6 +34,12 @@ Test YML-Nested
3434
Should Be Equal ${cfg}[${ENV}][user] dev_user
3535
Should Be Equal ${cfg}[${ENV}][password] dev_password
3636

37+
Test JSON-Nested
38+
[Documentation] How to load a nested data structure from a YAML variable file — same access syntax as Python dicts.
39+
Should Be Equal ${cookbook}[pasta][name] Spaghetti Carbonara
40+
Should Be Equal As Integers ${cookbook}[pasta][time_minutes] 20
41+
Should Contain ${cookbook}[dessert][ingredients] mascarpone
42+
3743
Test Get-Variables With Argument
3844
[Documentation] How to use a get_variables() function to return different variable sets based on an argument passed at import time.
3945
Should Be Equal ${BROWSER} chrome

0 commit comments

Comments
 (0)