holado 0.7.1__py3-none-any.whl → 0.8.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of holado might be problematic. Click here for more details.
- holado/common/context/context.py +107 -4
- holado/common/context/session_context.py +15 -5
- {holado-0.7.1.dist-info → holado-0.8.1.dist-info}/METADATA +6 -10
- {holado-0.7.1.dist-info → holado-0.8.1.dist-info}/RECORD +35 -30
- holado_context/tests/behave/steps/private/common/context_steps.py +35 -3
- holado_core/common/resource/persisted_method_to_call_manager.py +134 -27
- holado_core/common/tools/path_manager.py +47 -26
- holado_docker/tests/behave/steps/tools/docker_controller/client_steps.py +12 -9
- holado_docker/tools/docker_controller/client/rest/docker_controller_client.py +53 -5
- holado_docker/tools/docker_controller/server/rest/api/config.py +57 -0
- holado_docker/tools/docker_controller/server/rest/api/container.py +5 -5
- holado_docker/tools/docker_controller/server/rest/api/os.py +41 -0
- holado_docker/tools/docker_controller/server/rest/openapi.yaml +111 -0
- holado_docker/tools/docker_controller/server/run_docker_controller_in_docker.sh +2 -1
- holado_helper/docker/run_holado_test_nonreg_in_docker.sh +1 -1
- holado_helper/docker/run_terminal_in_docker.sh +1 -1
- holado_json/tests/behave/steps/ipc/json_steps.py +11 -0
- holado_python/common/iterables.py +8 -0
- holado_python/standard_library/ssl/resources/certificates/tcpbin.crt +16 -16
- holado_python/standard_library/ssl/resources/certificates/tcpbin.key +26 -26
- holado_rabbitmq/tools/rabbitmq/rabbitmq_client.py +0 -2
- holado_system/tests/behave/steps/system/file_steps.py +26 -8
- holado_test/common/context/scenario_context.py +3 -64
- holado_test/scenario/step_tools.py +22 -0
- holado_yaml/tests/behave/steps/yaml_steps.py +106 -9
- holado_yaml/yaml/enums.py +28 -0
- holado_yaml/yaml/pyyaml/pyyaml_client.py +72 -0
- holado_yaml/yaml/ruamel/ruamel_yaml_client.py +80 -0
- holado_yaml/yaml/yaml_client.py +195 -0
- holado_yaml/yaml/yaml_manager.py +57 -49
- test_holado/features/NonReg/holado_yaml/yaml.feature +304 -8
- test_holado/features/NonReg/scenario/scenario.feature +48 -4
- test_holado/logging.conf +1 -0
- holado_helper/docker/run_terminal_in_docker-with_docker_control.sh +0 -103
- {holado-0.7.1.dist-info → holado-0.8.1.dist-info}/WHEEL +0 -0
- {holado-0.7.1.dist-info → holado-0.8.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -9,6 +9,47 @@ info:
|
|
|
9
9
|
For example, it is usefull for a testing solution needing to restart a microservice of the SUT (System Under Test),
|
|
10
10
|
but the testing solution docker image has not the privileges to do it.
|
|
11
11
|
paths:
|
|
12
|
+
/os/env:
|
|
13
|
+
get:
|
|
14
|
+
description: "Get environment variable values"
|
|
15
|
+
requestBody:
|
|
16
|
+
content:
|
|
17
|
+
application/json:
|
|
18
|
+
schema:
|
|
19
|
+
type: "array"
|
|
20
|
+
items:
|
|
21
|
+
type: "string"
|
|
22
|
+
responses:
|
|
23
|
+
200:
|
|
24
|
+
description: "Environment variable values"
|
|
25
|
+
content:
|
|
26
|
+
application/json:
|
|
27
|
+
schema:
|
|
28
|
+
type: "array"
|
|
29
|
+
items:
|
|
30
|
+
type: "object"
|
|
31
|
+
|
|
32
|
+
/os/ls:
|
|
33
|
+
get:
|
|
34
|
+
description: "List directory filenames"
|
|
35
|
+
requestBody:
|
|
36
|
+
content:
|
|
37
|
+
application/json:
|
|
38
|
+
schema:
|
|
39
|
+
type: "object"
|
|
40
|
+
properties:
|
|
41
|
+
path:
|
|
42
|
+
type: string
|
|
43
|
+
responses:
|
|
44
|
+
200:
|
|
45
|
+
description: "Directory filenames"
|
|
46
|
+
content:
|
|
47
|
+
application/text:
|
|
48
|
+
schema:
|
|
49
|
+
type: "array"
|
|
50
|
+
items:
|
|
51
|
+
type: "string"
|
|
52
|
+
|
|
12
53
|
/container:
|
|
13
54
|
get:
|
|
14
55
|
description: "List containers and their status"
|
|
@@ -143,6 +184,76 @@ paths:
|
|
|
143
184
|
application/json:
|
|
144
185
|
schema:
|
|
145
186
|
type: "string"
|
|
187
|
+
|
|
188
|
+
/config/yaml_file:
|
|
189
|
+
get:
|
|
190
|
+
description: "Get content of a YAML file"
|
|
191
|
+
requestBody:
|
|
192
|
+
content:
|
|
193
|
+
application/json:
|
|
194
|
+
schema:
|
|
195
|
+
type: "object"
|
|
196
|
+
properties:
|
|
197
|
+
file_path:
|
|
198
|
+
type: string
|
|
199
|
+
responses:
|
|
200
|
+
200:
|
|
201
|
+
description: ""
|
|
202
|
+
content:
|
|
203
|
+
application/text:
|
|
204
|
+
schema:
|
|
205
|
+
type: "string"
|
|
206
|
+
patch:
|
|
207
|
+
description: "Update a YAML file"
|
|
208
|
+
requestBody:
|
|
209
|
+
content:
|
|
210
|
+
application/json:
|
|
211
|
+
schema:
|
|
212
|
+
type: "object"
|
|
213
|
+
properties:
|
|
214
|
+
file_path:
|
|
215
|
+
type: string
|
|
216
|
+
yaml_string:
|
|
217
|
+
type: string
|
|
218
|
+
with_backup:
|
|
219
|
+
type: "boolean"
|
|
220
|
+
default: false
|
|
221
|
+
backup_extension:
|
|
222
|
+
type: string
|
|
223
|
+
default: '.bak'
|
|
224
|
+
responses:
|
|
225
|
+
200:
|
|
226
|
+
description: ""
|
|
227
|
+
content:
|
|
228
|
+
application/json:
|
|
229
|
+
schema:
|
|
230
|
+
type: "string"
|
|
231
|
+
put:
|
|
232
|
+
description: "Replace a YAML file"
|
|
233
|
+
requestBody:
|
|
234
|
+
content:
|
|
235
|
+
application/json:
|
|
236
|
+
schema:
|
|
237
|
+
type: "object"
|
|
238
|
+
properties:
|
|
239
|
+
action:
|
|
240
|
+
description: "Action to perform"
|
|
241
|
+
type: string
|
|
242
|
+
enum:
|
|
243
|
+
- "restore"
|
|
244
|
+
file_path:
|
|
245
|
+
type: string
|
|
246
|
+
backup_extension:
|
|
247
|
+
type: string
|
|
248
|
+
default: '.bak'
|
|
249
|
+
responses:
|
|
250
|
+
200:
|
|
251
|
+
description: ""
|
|
252
|
+
content:
|
|
253
|
+
application/json:
|
|
254
|
+
schema:
|
|
255
|
+
type: "string"
|
|
256
|
+
|
|
146
257
|
components:
|
|
147
258
|
securitySchemes: {}
|
|
148
259
|
schemas:
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# Have access to any HolAdo registry.
|
|
13
13
|
#
|
|
14
14
|
# Optionally, define in .profile the following variables
|
|
15
|
+
# - HOLADO_DOCKER_CONTROLLER_NAME: name of the container
|
|
15
16
|
# - HOLADO_DOCKER_CONTROLLER_PORT: REST API port to use (default: 8000)
|
|
16
17
|
# - HOLADO_IMAGE_REGISTRY: docker image registry to use (default: holado/docker_controller)
|
|
17
18
|
# - HOLADO_IMAGE_TAG: docker image tag to use (default: latest)
|
|
@@ -89,7 +90,7 @@ echo " port: ${HOLADO_DOCKER_CONTROLLER_PORT}"
|
|
|
89
90
|
#echo " NETWORK_DEF_COMMAND=${NETWORK_DEF_COMMAND}"
|
|
90
91
|
echo
|
|
91
92
|
docker run --rm --user root --name ${HOLADO_DOCKER_CONTROLLER_NAME} \
|
|
92
|
-
--privileged -v /var/run/docker.sock:/var/run/docker.sock \
|
|
93
|
+
--privileged -v $(docker info | grep -i rootless > /dev/null && echo -n "/run/user/$(id -u ${USER})/docker.sock" || echo -n "/var/run/docker.sock"):/var/run/docker.sock \
|
|
93
94
|
-v "${OUTPUT_DIR}":/output \
|
|
94
95
|
-v "${RESOURCES_DIR}":/resources \
|
|
95
96
|
-e HOLADO_OUTPUT_BASEDIR=/output \
|
|
@@ -109,7 +109,7 @@ echo
|
|
|
109
109
|
echo "Running tests (docker name: ${HOLADO_RUNNER_NAME})..."
|
|
110
110
|
echo
|
|
111
111
|
# Note: In bellow command, some non-regression scenarios are skipped, those currently not working when run in docker
|
|
112
|
-
docker run --rm -t $(
|
|
112
|
+
docker run --rm -t $(docker info | grep -i rootless > /dev/null && echo -n "--user root" || echo -n "-u $(id -u ${USER}):$(id -g ${USER})") --name ${HOLADO_RUNNER_NAME} \
|
|
113
113
|
-v "${OUTPUT_DIR}":/output \
|
|
114
114
|
-v "${RESOURCES_DIR}":/resources \
|
|
115
115
|
${LOGGING_CONF_CMD} \
|
|
@@ -90,7 +90,7 @@ fi
|
|
|
90
90
|
echo
|
|
91
91
|
echo "Running tests (docker name: ${HOLADO_RUNNER_NAME})..."
|
|
92
92
|
echo
|
|
93
|
-
docker run --rm -it $(
|
|
93
|
+
docker run --rm -it $(docker info | grep -i rootless > /dev/null && echo -n "--user root" || echo -n "-u $(id -u ${USER}):$(id -g ${USER})") --name ${HOLADO_RUNNER_NAME} \
|
|
94
94
|
-v "${OUTPUT_DIR}":/output \
|
|
95
95
|
-v "${RESOURCES_DIR}":/resources \
|
|
96
96
|
-e HOLADO_OUTPUT_BASEDIR=/output \
|
|
@@ -22,6 +22,7 @@ import logging
|
|
|
22
22
|
from holado_value.common.tables.converters.value_table_converter import ValueTableConverter
|
|
23
23
|
from holado_core.common.tools.tools import Tools
|
|
24
24
|
from holado_json.ipc.json_converter import JsonConverter
|
|
25
|
+
from holado_test.behave.scenario.behave_step_tools import BehaveStepTools
|
|
25
26
|
|
|
26
27
|
logger = logging.getLogger(__name__)
|
|
27
28
|
|
|
@@ -107,6 +108,16 @@ def step_impl(context, var_name, json_text):
|
|
|
107
108
|
|
|
108
109
|
__get_variable_manager().register_variable(var_name, json_object)
|
|
109
110
|
|
|
111
|
+
@Step(r"(?P<var_name>{Variable}) = json object")
|
|
112
|
+
def step_impl(context, var_name):
|
|
113
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
114
|
+
json_text = BehaveStepTools.get_step_multiline_text(context)
|
|
115
|
+
|
|
116
|
+
converter = JsonConverter()
|
|
117
|
+
json_object = converter.to_json(json_text)
|
|
118
|
+
|
|
119
|
+
__get_variable_manager().register_variable(var_name, json_object)
|
|
120
|
+
|
|
110
121
|
@Step(r"(?P<var_name>{Variable}) = convert name/value table (?P<table_varname>{Variable}) to json")
|
|
111
122
|
def step_impl(context, var_name, table_varname):
|
|
112
123
|
var_name = StepTools.evaluate_variable_name(var_name)
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
import logging
|
|
17
|
+
from holado_core.common.exceptions.technical_exception import TechnicalException
|
|
18
|
+
from holado_python.standard_library.typing import Typing
|
|
17
19
|
|
|
18
20
|
logger = logging.getLogger(__name__)
|
|
19
21
|
|
|
@@ -27,4 +29,10 @@ def is_sorted(iterable, key=lambda x:x, reverse=False):
|
|
|
27
29
|
else:
|
|
28
30
|
return all(key(iterable[i]) <= key(iterable[i+1]) for i in range(len(iterable) - 1))
|
|
29
31
|
|
|
32
|
+
def remove_all(iterable, value):
|
|
33
|
+
if not isinstance(iterable, list):
|
|
34
|
+
raise TechnicalException(f"Unmanaged to remove all for iterable type {Typing.get_object_class_fullname(iterable)}")
|
|
30
35
|
|
|
36
|
+
new_list = [x for x in iterable if x != value]
|
|
37
|
+
del iterable[:]
|
|
38
|
+
iterable.extend(new_list)
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
MIIDZTCCAk2gAwIBAgIBKjANBgkqhkiG9w0BAQsFADCBizELMAkGA1UEBhMCVVMx
|
|
3
3
|
CzAJBgNVBAgMAkNBMRYwFAYDVQQHDA1TYW4gRnJhbmNpc2NvMQ8wDQYDVQQKDAZ0
|
|
4
4
|
Y3BiaW4xDDAKBgNVBAsMA29wczETMBEGA1UEAwwKdGNwYmluLmNvbTEjMCEGCSqG
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
FOLuMowBSAZfV5v82LmlaIIOvU/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
SIb3DQEJARYUaGFycnliYWdkaUBnbWFpbC5jb20wHhcNMjUwOTAxMTAxNDQ4WhcN
|
|
6
|
+
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nSzGvVAEwKyL0OXq4k3+o9Nj/KYqncXzJ
|
|
26
|
+
v8GmSyjEtSy1VynW8D1VAtCbfI7GHa+TflcjLqKb2BN+BpTGjeVPRbXVUlwqFF3I
|
|
27
|
+
ughugjyndVciKdl7MmifCz92
|
|
28
28
|
-----END PRIVATE KEY-----
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
# The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.
|
|
12
12
|
#################################################
|
|
13
13
|
|
|
14
|
-
import time
|
|
15
14
|
import logging
|
|
16
15
|
from holado_core.common.exceptions.functional_exception import FunctionalException
|
|
17
16
|
from holado_core.common.exceptions.technical_exception import TechnicalException
|
|
@@ -27,7 +26,6 @@ from holado_core.common.exceptions.verify_exception import VerifyException
|
|
|
27
26
|
import abc
|
|
28
27
|
from holado_multitask.multithreading.loopfunctionthreaded import LoopFunctionThreaded
|
|
29
28
|
from holado_multitask.multitasking.multitask_manager import MultitaskManager
|
|
30
|
-
from holado.common.tools.gc_manager import GcManager
|
|
31
29
|
|
|
32
30
|
|
|
33
31
|
logger = logging.getLogger(__name__)
|
|
@@ -46,6 +46,13 @@ def __get_path_manager():
|
|
|
46
46
|
return SessionContext.instance().path_manager
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
@Then(r"file (?P<path>{Str}) (?P<exists_str>exists|doesn't exist)")
|
|
50
|
+
def step_impl(context, path, exists_str): # @DuplicatedSignature
|
|
51
|
+
path = StepTools.evaluate_scenario_parameter(path)
|
|
52
|
+
exists = exists_str == "exists"
|
|
53
|
+
|
|
54
|
+
__get_path_manager().check_file_exists(path, do_exist=exists, raise_exception=True)
|
|
55
|
+
|
|
49
56
|
@Given(r"(?P<var_name>{Variable}) = is path (?P<path>{Str}) an absolute file path")
|
|
50
57
|
def step_impl(context, var_name, path): # @DuplicatedSignature
|
|
51
58
|
var_name = StepTools.evaluate_variable_name(var_name)
|
|
@@ -112,27 +119,38 @@ def step_impl(context, data, file):
|
|
|
112
119
|
|
|
113
120
|
file.write(data)
|
|
114
121
|
|
|
115
|
-
@Given(r"(?P<var_name>{Variable}) = content of file (?P<path>{Str})")
|
|
116
|
-
def step_impl(context, var_name, path): # @DuplicatedSignature
|
|
122
|
+
@Given(r"(?P<var_name>{Variable}) = content of(?:(?P<is_text_file_str> text))? file (?P<path>{Str})")
|
|
123
|
+
def step_impl(context, var_name, is_text_file_str, path): # @DuplicatedSignature
|
|
117
124
|
var_name = StepTools.evaluate_variable_name(var_name)
|
|
125
|
+
is_text_file = is_text_file_str is not None
|
|
118
126
|
path = StepTools.evaluate_scenario_parameter(path)
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
|
|
128
|
+
mode = 'rt' if is_text_file else 'rb'
|
|
129
|
+
with open(path, mode) as fin:
|
|
130
|
+
res = fin.read()
|
|
131
|
+
|
|
132
|
+
__get_variable_manager().register_variable(var_name, res)
|
|
121
133
|
|
|
122
134
|
@Given(r"(?P<var_name>{Variable}) = content of file (?P<path>{Str}) in base 64")
|
|
123
135
|
def step_impl(context, var_name, path): # @DuplicatedSignature
|
|
124
136
|
var_name = StepTools.evaluate_variable_name(var_name)
|
|
125
137
|
path = StepTools.evaluate_scenario_parameter(path)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
138
|
+
|
|
139
|
+
with open(path, "rb") as fin:
|
|
140
|
+
content = fin.read()
|
|
141
|
+
res = base64.b64encode(content)
|
|
142
|
+
|
|
143
|
+
__get_variable_manager().register_variable(var_name, res)
|
|
129
144
|
|
|
130
145
|
@Given(r"(?P<var_name>{Variable}) = lines of file (?P<path>{Str})")
|
|
131
146
|
def step_impl(context, var_name, path): # @DuplicatedSignature
|
|
132
147
|
var_name = StepTools.evaluate_variable_name(var_name)
|
|
133
148
|
path = StepTools.evaluate_scenario_parameter(path)
|
|
134
|
-
|
|
149
|
+
|
|
150
|
+
with open(path, "r") as fin:
|
|
151
|
+
lines = fin.readlines()
|
|
135
152
|
res = list(map(lambda x: x.strip('\n'), lines))
|
|
153
|
+
|
|
136
154
|
__get_variable_manager().register_variable(var_name, res)
|
|
137
155
|
|
|
138
156
|
|
|
@@ -24,8 +24,6 @@ from holado_core.common.block.block_manager import BlockManager
|
|
|
24
24
|
from datetime import datetime
|
|
25
25
|
from holado_core.common.exceptions.technical_exception import TechnicalException
|
|
26
26
|
from holado_scripting.text.verifier.text_verifier import TextVerifier
|
|
27
|
-
from holado_core.common.resource.persisted_method_to_call_manager import PersistedMethodToCallManager
|
|
28
|
-
from holado_python.standard_library.typing import Typing
|
|
29
27
|
from holado_multitask.multitasking.multitask_manager import MultitaskManager
|
|
30
28
|
|
|
31
29
|
logger = logging.getLogger(__name__)
|
|
@@ -33,7 +31,7 @@ logger = logging.getLogger(__name__)
|
|
|
33
31
|
|
|
34
32
|
class ScenarioContext(Context):
|
|
35
33
|
def __init__(self, scenario):
|
|
36
|
-
super().__init__("Scenario")
|
|
34
|
+
super().__init__("Scenario", with_post_process=True)
|
|
37
35
|
|
|
38
36
|
self.__scenario = scenario
|
|
39
37
|
|
|
@@ -43,14 +41,6 @@ class ScenarioContext(Context):
|
|
|
43
41
|
self.__main_thread_uid = SessionContext.instance().multitask_manager.main_thread_uid
|
|
44
42
|
self.__steps_by_thread_uid = {}
|
|
45
43
|
|
|
46
|
-
# Post process management
|
|
47
|
-
self.__persisted_method_to_call_manager = PersistedMethodToCallManager()
|
|
48
|
-
self.__persisted_method_to_call_manager.initialize(SessionContext.instance().resource_manager, SessionContext.instance().expression_evaluator)
|
|
49
|
-
self.__post_process_funcs = []
|
|
50
|
-
|
|
51
|
-
def initialize(self):
|
|
52
|
-
self.__persisted_method_to_call_manager.ensure_persistent_db_exists()
|
|
53
|
-
|
|
54
44
|
def __str__(self):
|
|
55
45
|
return f"{{ScenarioContext({id(self)}):{self.scenario.name}}}"
|
|
56
46
|
|
|
@@ -161,57 +151,6 @@ class ScenarioContext(Context):
|
|
|
161
151
|
|
|
162
152
|
def end(self):
|
|
163
153
|
self.__end_date = datetime.now()
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
### Post process management
|
|
167
|
-
|
|
168
|
-
def add_post_process(self, func):
|
|
169
|
-
success = self.__persist_function(func)
|
|
170
|
-
if not success:
|
|
171
|
-
logger.debug(f"Add scenario post process in memory, persistence in DB has failed (post process function: {func})")
|
|
172
|
-
self.__post_process_funcs.append(func)
|
|
173
|
-
|
|
174
|
-
def __persist_function(self, func):
|
|
175
|
-
try:
|
|
176
|
-
if Typing.is_function(func._target):
|
|
177
|
-
func_qualname = Typing.get_function_fullname(func._target)
|
|
178
|
-
self.__persisted_method_to_call_manager.add_function_to_call(func_qualname, args_list=func._args, kwargs_dict=func._kwargs, use="scenario_post_process", use_index=None)
|
|
179
|
-
return True
|
|
180
|
-
elif Typing.is_method(func._target):
|
|
181
|
-
meth_func = Typing.get_method_function(func._target)
|
|
182
|
-
func_qualname = Typing.get_function_fullname(meth_func)
|
|
183
|
-
meth_obj = Typing.get_method_object_instance(func._target)
|
|
184
|
-
self_getter_eval_str = SessionContext.instance().get_object_getter_eval_string(meth_obj, raise_not_found=False)
|
|
185
|
-
if self_getter_eval_str is not None:
|
|
186
|
-
self.__persisted_method_to_call_manager.add_method_to_call(func_qualname, self_getter_eval_str, args_list=func._args, kwargs_dict=func._kwargs, use="scenario_post_process", use_index=None)
|
|
187
|
-
return True
|
|
188
|
-
else:
|
|
189
|
-
raise TechnicalException(f"Unmanaged target type '{Typing.get_object_class_fullname(func._target)}'")
|
|
190
|
-
except TechnicalException as exc:
|
|
191
|
-
raise exc
|
|
192
|
-
except Exception as exc:
|
|
193
|
-
logger.warning(f"Failed to persist function {func}: {exc}")
|
|
194
|
-
return False
|
|
195
|
-
|
|
196
|
-
def do_post_processes(self):
|
|
197
|
-
# First call functions that were not persisted
|
|
198
|
-
for func in self.__post_process_funcs:
|
|
199
|
-
try:
|
|
200
|
-
func.run()
|
|
201
|
-
except Exception as exc:
|
|
202
|
-
# logger.error(f"Error while post processing [{func}]: {exc}")
|
|
203
|
-
logger.exception(f"Error while scenario post processing [{func}]: {exc}")
|
|
204
|
-
|
|
205
|
-
# Call persisted functions and methods
|
|
206
|
-
try:
|
|
207
|
-
self.__persisted_method_to_call_manager.call_functions_and_methods(use="scenario_post_process", delete_after_call=True)
|
|
208
|
-
except Exception as exc:
|
|
209
|
-
logger.exception(f"Error while scenario post processing persisted methods: {exc}")
|
|
210
|
-
|
|
211
|
-
def do_previous_scenario_post_processes(self):
|
|
212
|
-
"""Call functions and methods persisted by a previous scenario
|
|
213
|
-
Note: This is useful especially when a scenario execution was interrupted before post processes could be performed
|
|
214
|
-
"""
|
|
215
|
-
self.__persisted_method_to_call_manager.call_functions_and_methods(use="scenario_post_process", delete_after_call=True)
|
|
216
|
-
|
|
154
|
+
|
|
155
|
+
|
|
217
156
|
|
|
@@ -398,6 +398,28 @@ class StepTools(object):
|
|
|
398
398
|
except FunctionalException as exc:
|
|
399
399
|
raise FunctionalException(f"Obtained table contains at least a row of expected table (obtained = table 1 ; expected = table 2):\n{Tools.indent_string(4, exc.message)}") from exc
|
|
400
400
|
|
|
401
|
+
@classmethod
|
|
402
|
+
def format_step(cls, step_str, keyword=None, table=None, text=None):
|
|
403
|
+
step_str = step_str.strip()
|
|
404
|
+
|
|
405
|
+
if keyword is not None:
|
|
406
|
+
res = f"{keyword} {step_str}"
|
|
407
|
+
else:
|
|
408
|
+
res = step_str
|
|
409
|
+
|
|
410
|
+
if table is not None:
|
|
411
|
+
if isinstance(table, Table):
|
|
412
|
+
rendered_table = table.represent(indent=4)
|
|
413
|
+
else:
|
|
414
|
+
raise TechnicalException(f"Unmanaged table of type '{Typing.get_object_class_fullname(table)}'")
|
|
415
|
+
res = u"{res}\n{table}".format(res=res, table=rendered_table)
|
|
416
|
+
elif text is not None:
|
|
417
|
+
rendered_text = text.replace(u'"""', u'\\"\\"\\"')
|
|
418
|
+
rendered_text = Tools.indent_string(4, u'"""\n' + rendered_text + '\n"""\n')
|
|
419
|
+
res = u"{res}\n{text}".format(res=res, text=rendered_text)
|
|
420
|
+
|
|
421
|
+
return res
|
|
422
|
+
|
|
401
423
|
@classmethod
|
|
402
424
|
def format_steps_with(cls, steps, format_with_list):
|
|
403
425
|
res = steps
|
|
@@ -18,6 +18,7 @@ from holado.common.context.session_context import SessionContext
|
|
|
18
18
|
from holado_test.behave.behave import * # @UnusedWildImport
|
|
19
19
|
import logging
|
|
20
20
|
from holado_yaml.yaml.yaml_manager import YAMLManager
|
|
21
|
+
from holado_test.behave.scenario.behave_step_tools import BehaveStepTools
|
|
21
22
|
|
|
22
23
|
logger = logging.getLogger(__name__)
|
|
23
24
|
|
|
@@ -33,31 +34,127 @@ if YAMLManager.is_available():
|
|
|
33
34
|
def __get_path_manager():
|
|
34
35
|
return SessionContext.instance().path_manager
|
|
35
36
|
|
|
37
|
+
def __get_client(client_type, client):
|
|
38
|
+
client_type = StepTools.evaluate_scenario_parameter(client_type)
|
|
39
|
+
client = StepTools.evaluate_variable_name(client)
|
|
40
|
+
|
|
41
|
+
if client is None:
|
|
42
|
+
return YAMLManager.get_client(client_type)
|
|
43
|
+
else:
|
|
44
|
+
return client
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@Step(r"(?P<var_name>{Variable}) = new YAML client(?: \(client type: (?P<client_type>{Str})\))?")
|
|
48
|
+
def step_impl(context, var_name, client_type):
|
|
49
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
50
|
+
client_type = StepTools.evaluate_scenario_parameter(client_type)
|
|
51
|
+
|
|
52
|
+
res = YAMLManager.get_client(client_type)
|
|
53
|
+
|
|
54
|
+
__get_variable_manager().register_variable(var_name, res)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# Manage YAML objects
|
|
58
|
+
|
|
59
|
+
@Step(r"(?P<var_name>{Variable}) = YAML object(?: \((?:client type: (?P<client_type>{Str}))?(?: ; )?(?:client: (?P<client>{Variable}))?\))?")
|
|
60
|
+
def step_impl(context, var_name, client_type, client):
|
|
61
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
62
|
+
client = __get_client(client_type, client)
|
|
63
|
+
text = BehaveStepTools.get_step_multiline_text(context)
|
|
64
|
+
|
|
65
|
+
res = client.load_string(text)
|
|
66
|
+
|
|
67
|
+
__get_variable_manager().register_variable(var_name, res)
|
|
68
|
+
|
|
69
|
+
@Step(r"update YAML object (?P<obj>{Variable}) with data (?P<data>{Variable})(?: \((?:client type: (?P<client_type>{Str}))?(?: ; )?(?:client: (?P<client>{Variable}))?\))?")
|
|
70
|
+
def step_impl(context, obj, data, client_type, client): # @DuplicatedSignature
|
|
71
|
+
obj = StepTools.evaluate_scenario_parameter(obj)
|
|
72
|
+
data = StepTools.evaluate_scenario_parameter(data)
|
|
73
|
+
client = __get_client(client_type, client)
|
|
74
|
+
|
|
75
|
+
client.update_data(obj, data)
|
|
76
|
+
|
|
77
|
+
@Step(r"(?P<var_name>{Variable}) = convert YAML object (?P<obj>{Variable}) to string(?: \((?:client type: (?P<client_type>{Str}))?(?: ; )?(?:client: (?P<client>{Variable}))?\))?")
|
|
78
|
+
def step_impl(context, var_name, obj, client_type, client): # @DuplicatedSignature
|
|
79
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
80
|
+
obj = StepTools.evaluate_scenario_parameter(obj)
|
|
81
|
+
client = __get_client(client_type, client)
|
|
82
|
+
|
|
83
|
+
res = client.save_in_string(obj)
|
|
84
|
+
|
|
85
|
+
__get_variable_manager().register_variable(var_name, res)
|
|
36
86
|
|
|
37
|
-
|
|
38
|
-
|
|
87
|
+
|
|
88
|
+
# Manage YAML strings
|
|
89
|
+
|
|
90
|
+
@Step(r"(?P<var_name>{Variable}) = load YAML string (?P<text>{Str})(?: \((?:client type: (?P<client_type>{Str}))?(?: ; )?(?:client: (?P<client>{Variable}))?\))?")
|
|
91
|
+
def step_impl(context, var_name, text, client_type, client): # @DuplicatedSignature
|
|
92
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
93
|
+
text = StepTools.evaluate_scenario_parameter(text)
|
|
94
|
+
client = __get_client(client_type, client)
|
|
95
|
+
|
|
96
|
+
res = YAMLManager.load_string(text, client_type=client_type)
|
|
97
|
+
|
|
98
|
+
__get_variable_manager().register_variable(var_name, res)
|
|
99
|
+
|
|
100
|
+
@Step(r"(?P<var_name>{Variable}) = update YAML string (?P<text>{Str}) with data (?P<data>{Variable})(?: \((?:client type: (?P<client_type>{Str}))?(?: ; )?(?:client: (?P<client>{Variable}))?\))?")
|
|
101
|
+
def step_impl(context, var_name, text, data, client_type, client): # @DuplicatedSignature
|
|
102
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
103
|
+
text = StepTools.evaluate_scenario_parameter(text)
|
|
104
|
+
data = StepTools.evaluate_scenario_parameter(data)
|
|
105
|
+
client = __get_client(client_type, client)
|
|
106
|
+
|
|
107
|
+
res = YAMLManager.update_string(text, data, client=client)
|
|
108
|
+
|
|
109
|
+
__get_variable_manager().register_variable(var_name, res)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
# Manage YAML files
|
|
113
|
+
|
|
114
|
+
@Step(r"(?P<var_name>{Variable}) = load YAML file (?P<path>{Str})(?: \((?:client type: (?P<client_type>{Str}))?(?: ; )?(?:client: (?P<client>{Variable}))?\))?")
|
|
115
|
+
def step_impl(context, var_name, path, client_type, client): # @DuplicatedSignature
|
|
39
116
|
var_name = StepTools.evaluate_variable_name(var_name)
|
|
40
117
|
path = StepTools.evaluate_scenario_parameter(path)
|
|
118
|
+
client = __get_client(client_type, client)
|
|
41
119
|
|
|
42
|
-
res = YAMLManager.load_file(path,
|
|
120
|
+
res = YAMLManager.load_file(path, client=client)
|
|
43
121
|
|
|
44
122
|
__get_variable_manager().register_variable(var_name, res)
|
|
45
123
|
|
|
46
|
-
@Step(r"(?P<var_name>{Variable}) = load multiple documents YAML file (?P<path>{Str})(?:(?P<
|
|
47
|
-
def step_impl(context, var_name, path,
|
|
124
|
+
@Step(r"(?P<var_name>{Variable}) = load multiple documents YAML file (?P<path>{Str})(?: \((?:client type: (?P<client_type>{Str}))?(?: ; )?(?:client: (?P<client>{Variable}))?\))?")
|
|
125
|
+
def step_impl(context, var_name, path, client_type, client): # @DuplicatedSignature
|
|
48
126
|
var_name = StepTools.evaluate_variable_name(var_name)
|
|
49
127
|
path = StepTools.evaluate_scenario_parameter(path)
|
|
128
|
+
client = __get_client(client_type, client)
|
|
50
129
|
|
|
51
|
-
res = YAMLManager.load_multiple_documents_file(path,
|
|
130
|
+
res = YAMLManager.load_multiple_documents_file(path, client=client)
|
|
52
131
|
|
|
53
132
|
__get_variable_manager().register_variable(var_name, res)
|
|
54
133
|
|
|
55
|
-
@Step(r"save (?P<data>{Variable}) in YAML file (?P<path>{Str})")
|
|
56
|
-
def step_impl(context, data, path): # @DuplicatedSignature
|
|
134
|
+
@Step(r"save (?P<data>{Variable}) in YAML file (?P<path>{Str})(?: \((?:client type: (?P<client_type>{Str}))?(?: ; )?(?:client: (?P<client>{Variable}))?\))?")
|
|
135
|
+
def step_impl(context, data, path, client_type, client): # @DuplicatedSignature
|
|
57
136
|
data = StepTools.evaluate_scenario_parameter(data)
|
|
58
137
|
path = StepTools.evaluate_scenario_parameter(path)
|
|
138
|
+
client = __get_client(client_type, client)
|
|
139
|
+
|
|
140
|
+
YAMLManager.save_in_file(path, data, client=client)
|
|
141
|
+
|
|
142
|
+
@Step(r"update YAML file (?P<path>{Str}) with data (?P<data>{Variable})(?: \((?:client type: (?P<client_type>{Str}))?(?: ; )?(?:client: (?P<client>{Variable}))?(?: ; )?(?:(?P<with_backup_str>with backup))?(?: ; )?(?:backup extension: (?P<backup_extension>{Str}))?\))?")
|
|
143
|
+
def step_impl(context, path, data, client_type, client, with_backup_str, backup_extension): # @DuplicatedSignature
|
|
144
|
+
path = StepTools.evaluate_scenario_parameter(path)
|
|
145
|
+
data = StepTools.evaluate_scenario_parameter(data)
|
|
146
|
+
client = __get_client(client_type, client)
|
|
147
|
+
with_backup = with_backup_str is not None
|
|
148
|
+
backup_extension = StepTools.evaluate_scenario_parameter(backup_extension)
|
|
149
|
+
|
|
150
|
+
YAMLManager.update_file(path, data, client=client, with_backup=with_backup, backup_extension=backup_extension)
|
|
151
|
+
|
|
152
|
+
@Step(r"restore YAML file (?P<path>{Str})(?: \((?:backup extension: (?P<backup_extension>{Str}))?\))?")
|
|
153
|
+
def step_impl(context, path, backup_extension): # @DuplicatedSignature
|
|
154
|
+
path = StepTools.evaluate_scenario_parameter(path)
|
|
155
|
+
backup_extension = StepTools.evaluate_scenario_parameter(backup_extension)
|
|
59
156
|
|
|
60
|
-
YAMLManager.
|
|
157
|
+
YAMLManager.restore_file(path, backup_extension=backup_extension)
|
|
61
158
|
|
|
62
159
|
|
|
63
160
|
|