Skip to content

Commit 323f17d

Browse files
committed
Add Bad example
1 parent b2c4611 commit 323f17d

File tree

11 files changed

+369
-17
lines changed

11 files changed

+369
-17
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 15 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

je_auto_control/utils/project/create_project_structure.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
from je_auto_control.utils.json.json_file import write_action_json
66
from je_auto_control.utils.project.template.template_executor import executor_template_1, \
7-
executor_template_2
7+
executor_template_2, bad_executor_template_1
88
from je_auto_control.utils.project.template.template_keyword import template_keyword_1, \
9-
template_keyword_2
9+
template_keyword_2, bad_template_1
1010

1111

1212
def create_dir(dir_name: str) -> None:
@@ -27,6 +27,7 @@ def create_template(parent_name: str) -> None:
2727
if keyword_dir_path.exists() and keyword_dir_path.is_dir():
2828
write_action_json(getcwd() + "/" + parent_name + "/keyword/keyword1.json", template_keyword_1)
2929
write_action_json(getcwd() + "/" + parent_name + "/keyword/keyword2.json", template_keyword_2)
30+
write_action_json(getcwd() + "/" + parent_name + "/keyword/bad_keyword_1.json", bad_template_1)
3031
if executor_dir_path.exists() and keyword_dir_path.is_dir():
3132
lock.acquire()
3233
try:
@@ -37,6 +38,13 @@ def create_template(parent_name: str) -> None:
3738
getcwd() + "/" + parent_name + "/keyword/keyword1.json"
3839
)
3940
)
41+
with open(getcwd() + "/" + parent_name + "/executor/executor_bad_file.py", "w+") as file:
42+
file.write(
43+
bad_executor_template_1.replace(
44+
"{temp}",
45+
getcwd() + "/" + parent_name + "/keyword/bad_keyword_1.json"
46+
)
47+
)
4048
with open(getcwd() + "/" + parent_name + "/executor/executor_folder.py", "w+") as file:
4149
file.write(
4250
executor_template_2.replace(

je_auto_control/utils/project/template/template_executor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,15 @@
1717
)
1818
)
1919
"""
20+
21+
bad_executor_template_1: str = \
22+
"""
23+
# This example is primarily intended to remind users of the importance of verifying input.
24+
from je_auto_control import execute_action, read_action_json
25+
26+
execute_action(
27+
read_action_json(
28+
r"{temp}"
29+
)
30+
)
31+
"""

je_auto_control/utils/project/template/template_keyword.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,9 @@
4848
["generate_json_report"]
4949
]
5050

51+
bad_template_1 = [
52+
["set_record_enable", [True]],
53+
["add_package_to_executor", ["os"]],
54+
["os_system", ["python --version"]],
55+
["os_system", ["python -m pip --version"]],
56+
]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# This example is primarily intended to remind users of the importance of verifying input.
3+
from je_auto_control import execute_action, read_action_json
4+
5+
execute_action(
6+
read_action_json(
7+
r"C:\Users\JeffreyChen\Desktop\Code_Space\AutoControl\test\unit_test\create_project_file/My Test Project/keyword/bad_keyword_1.json"
8+
)
9+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from je_auto_control import execute_files, get_dir_files_as_list
2+
3+
execute_files(
4+
get_dir_files_as_list(
5+
r"C:\Users\JeffreyChen\Desktop\Code_Space\AutoControl\test\unit_test\create_project_file/My Test Project/keyword"
6+
)
7+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from je_auto_control import execute_action, read_action_json
2+
3+
execute_action(
4+
read_action_json(
5+
r"C:\Users\JeffreyChen\Desktop\Code_Space\AutoControl\test\unit_test\create_project_file/My Test Project/keyword/keyword1.json"
6+
)
7+
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[
2+
[
3+
"set_record_enable",
4+
[
5+
true
6+
]
7+
],
8+
[
9+
"add_package_to_executor",
10+
[
11+
"os"
12+
]
13+
],
14+
[
15+
"os_system",
16+
[
17+
"python --version"
18+
]
19+
],
20+
[
21+
"os_system",
22+
[
23+
"python -m pip --version"
24+
]
25+
]
26+
]
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
[
2+
[
3+
"set_record_enable",
4+
[
5+
true
6+
]
7+
],
8+
[
9+
"write",
10+
{
11+
"write_string": "Hello World"
12+
}
13+
],
14+
[
15+
"type_keyboard",
16+
{
17+
"keycode": "return"
18+
}
19+
],
20+
[
21+
"write",
22+
{
23+
"write_string": "If you want Windows write upcase string"
24+
}
25+
],
26+
[
27+
"type_keyboard",
28+
{
29+
"keycode": "return"
30+
}
31+
],
32+
[
33+
"write",
34+
{
35+
"write_string": "you need to press shift first"
36+
}
37+
],
38+
[
39+
"type_keyboard",
40+
{
41+
"keycode": "return"
42+
}
43+
],
44+
[
45+
"press_keyboard_key",
46+
{
47+
"keycode": "shift"
48+
}
49+
],
50+
[
51+
"write",
52+
{
53+
"write_string": "UPCASEE"
54+
}
55+
],
56+
[
57+
"release_keyboard_key",
58+
{
59+
"keycode": "shift"
60+
}
61+
],
62+
[
63+
"type_keyboard",
64+
{
65+
"keycode": "return"
66+
}
67+
],
68+
[
69+
"write",
70+
{
71+
"write_string": "this is example how to use keyword"
72+
}
73+
],
74+
[
75+
"write",
76+
{
77+
"write_string": " and add module to executor"
78+
}
79+
],
80+
[
81+
"type_keyboard",
82+
{
83+
"keycode": "return"
84+
}
85+
],
86+
[
87+
"write",
88+
{
89+
"write_string": "now i will add time module and sleep 3 sec"
90+
}
91+
],
92+
[
93+
"add_package_to_executor",
94+
[
95+
"time"
96+
]
97+
],
98+
[
99+
"time_sleep",
100+
[
101+
3
102+
]
103+
],
104+
[
105+
"type_keyboard",
106+
{
107+
"keycode": "return"
108+
}
109+
],
110+
[
111+
"write",
112+
{
113+
"write_string": "also you can use builtin function on executor like print"
114+
}
115+
],
116+
[
117+
"print",
118+
[
119+
"Google Bye World"
120+
]
121+
],
122+
[
123+
"type_keyboard",
124+
{
125+
"keycode": "return"
126+
}
127+
],
128+
[
129+
"write",
130+
{
131+
"write_string": "and i will create an html report for you"
132+
}
133+
],
134+
[
135+
"generate_html_report"
136+
],
137+
[
138+
"type_keyboard",
139+
{
140+
"keycode": "return"
141+
}
142+
]
143+
]

0 commit comments

Comments
 (0)