holado 0.7.1__py3-none-any.whl → 0.8.0__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.

Files changed (35) hide show
  1. holado/common/context/context.py +110 -4
  2. holado/common/context/session_context.py +16 -5
  3. {holado-0.7.1.dist-info → holado-0.8.0.dist-info}/METADATA +4 -3
  4. {holado-0.7.1.dist-info → holado-0.8.0.dist-info}/RECORD +34 -29
  5. holado_context/tests/behave/steps/private/common/context_steps.py +35 -3
  6. holado_core/common/resource/persisted_method_to_call_manager.py +134 -27
  7. holado_core/common/tools/path_manager.py +47 -26
  8. holado_docker/tests/behave/steps/tools/docker_controller/client_steps.py +12 -9
  9. holado_docker/tools/docker_controller/client/rest/docker_controller_client.py +53 -5
  10. holado_docker/tools/docker_controller/server/rest/api/config.py +49 -0
  11. holado_docker/tools/docker_controller/server/rest/api/container.py +5 -5
  12. holado_docker/tools/docker_controller/server/rest/api/os.py +41 -0
  13. holado_docker/tools/docker_controller/server/rest/openapi.yaml +94 -0
  14. holado_docker/tools/docker_controller/server/run_docker_controller_in_docker.sh +2 -1
  15. holado_helper/docker/run_holado_test_nonreg_in_docker.sh +1 -1
  16. holado_helper/docker/run_terminal_in_docker.sh +1 -1
  17. holado_json/tests/behave/steps/ipc/json_steps.py +11 -0
  18. holado_python/common/iterables.py +8 -0
  19. holado_python/standard_library/ssl/resources/certificates/tcpbin.crt +16 -16
  20. holado_python/standard_library/ssl/resources/certificates/tcpbin.key +26 -26
  21. holado_rabbitmq/tools/rabbitmq/rabbitmq_client.py +0 -2
  22. holado_system/tests/behave/steps/system/file_steps.py +14 -3
  23. holado_test/common/context/scenario_context.py +3 -64
  24. holado_yaml/tests/behave/steps/yaml_steps.py +106 -9
  25. holado_yaml/yaml/enums.py +28 -0
  26. holado_yaml/yaml/pyyaml/pyyaml_client.py +72 -0
  27. holado_yaml/yaml/ruamel/ruamel_yaml_client.py +80 -0
  28. holado_yaml/yaml/yaml_client.py +195 -0
  29. holado_yaml/yaml/yaml_manager.py +57 -49
  30. test_holado/features/NonReg/holado_yaml/yaml.feature +304 -8
  31. test_holado/features/NonReg/scenario/scenario.feature +48 -4
  32. test_holado/logging.conf +1 -0
  33. holado_helper/docker/run_terminal_in_docker-with_docker_control.sh +0 -103
  34. {holado-0.7.1.dist-info → holado-0.8.0.dist-info}/WHEEL +0 -0
  35. {holado-0.7.1.dist-info → holado-0.8.0.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,59 @@ paths:
143
184
  application/json:
144
185
  schema:
145
186
  type: "string"
187
+
188
+ /config/yaml_file:
189
+ patch:
190
+ description: "Update a YAML file"
191
+ requestBody:
192
+ content:
193
+ application/json:
194
+ schema:
195
+ type: "object"
196
+ properties:
197
+ file_path:
198
+ type: string
199
+ yaml_string:
200
+ type: string
201
+ with_backup:
202
+ type: "boolean"
203
+ default: false
204
+ backup_extension:
205
+ type: string
206
+ default: '.bak'
207
+ responses:
208
+ 200:
209
+ description: ""
210
+ content:
211
+ application/json:
212
+ schema:
213
+ type: "string"
214
+ patch:
215
+ description: "Replace a YAML file"
216
+ requestBody:
217
+ content:
218
+ application/json:
219
+ schema:
220
+ type: "object"
221
+ properties:
222
+ action:
223
+ description: "Action to perform"
224
+ type: string
225
+ enum:
226
+ - "restore"
227
+ file_path:
228
+ type: string
229
+ backup_extension:
230
+ type: string
231
+ default: '.bak'
232
+ responses:
233
+ 200:
234
+ description: ""
235
+ content:
236
+ application/json:
237
+ schema:
238
+ type: "string"
239
+
146
240
  components:
147
241
  securitySchemes: {}
148
242
  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 $((docker info | grep -i rootless > /dev/null && echo -n "--user root") || echo -n "-u $(id -u ${USER}):$(id -g ${USER})") --name ${HOLADO_RUNNER_NAME} \
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 $((docker info | grep -i rootless > /dev/null && echo -n "--user root") || echo -n "-u $(id -u ${USER}):$(id -g ${USER})") --name ${HOLADO_RUNNER_NAME} \
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
- SIb3DQEJARYUaGFycnliYWdkaUBnbWFpbC5jb20wHhcNMjUwODAxMTcyMTEzWhcN
6
- MjUwODAyMTcyMTEzWjAcMRowGAYDVQQDDBF0Y3BiaW4uY29tLWNsaWVudDCCASIw
7
- DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMb4NMxoGghdBn/I/dg0FERytyuY
8
- l9PilUcZ0T1nKSMACigQKW4uBUzWIhZ85j9Yseve7Cl3saJRsNegbhTpdhs+OVhV
9
- CtfLZewYsEi+lIe4d0+6hz9EZTtF/mOivygXpL7kQdjTPfxwUehFWi8fvzd8o2ow
10
- Bghd4o+IRY5/b2xUNoUTDesasn3yY39TjP0Qa1SesM/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ox6WpzmDGbT1o6uU
14
+ A2D+Vdj0rbEtUeVq1B5oZmMPNzzHSxTOgr74k7KXkk/CeERbdnb3UAJgT0lVTlD1
15
+ G7IdEMwXbaZDhkkZlP/1+yhqfY6BXVdiozwp0hV264jWpQQ4Z3+i1JRNa0CJtTCj
16
+ M1/bYRymiDwm78p7/9ZP0YjD2QKBgQDN/PaLkiM6azOaXySW0UMHlQjY+c47TS9u
17
+ VPnHCIr4NP2oK9N4S1wjJJfMjvF2NbwQ31dx6hOCbIoYeX9Ttp8pLYvpI8mdK8+X
18
+ 8EehDlrGMzY6EVPrHuAELlBNPp/iDqpqBDyXsNoTdJlxxGmgfYUaY9tnIzuYIsTR
19
+ 56SIwLOQUwKBgCBq5hPkYLe57pym6KczDHjdoOUUUedXhB4NauOL4SkYxQ7BRTPp
20
+ 1lgILL70aHNSnvxE8vAzzfX7Hd7KbWaQDOz/UrBOjdC/nEB7XoAm7uMw3vy3EzPK
21
+ 1hFyIZrozsynlITiudMFv1Hh96ebp68e4RIXNkxaJU6169P7gd1MFvyZAoGAVb8U
22
+ nlryATJ446zxXTq1DWXzream+7aQpPwIkdqzhskAQk4kFHJCY3qrGgLy7sNFizx9
23
+ eTT4dBVckv2YjC98J7cHA8Da/2sqWlQybQ+9p73Pt/JYnYpXtEXXNaB5C7ARLlqf
24
+ IoIC9ZBXA63AToeRrb+dqFxZRWZLyhkEO80DsnMCgYBiMQQfXXvStKGvEUFI3DGB
25
+ e27HByFdIYGiSd90crg8VmW7iFJl03v/10hQaaBDR8L1u28ni10p8Rqtfmf9hqEz
26
+ S+OOxFvJOoEbjZ4b/0QI+Uz1u3E/+/asoRq1czTiU/bKdic5CaYuWOAhZhTMFbX8
27
+ Yx8xkRen+8bY3oXMsbOBJA==
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,11 +119,15 @@ 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
- content = open(path, "rb").read()
127
+
128
+ mode = 'rt' if is_text_file else 'rb'
129
+ content = open(path, mode).read()
130
+
120
131
  __get_variable_manager().register_variable(var_name, content)
121
132
 
122
133
  @Given(r"(?P<var_name>{Variable}) = content of file (?P<path>{Str}) in base 64")
@@ -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
 
@@ -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
- @Step(r"(?P<var_name>{Variable}) = load YAML file (?P<path>{Str})(?:(?P<with_only_strings_str> \(with only strings\))|(?P<with_full_yaml_features_str> \(with full YAML features\)))?")
38
- def step_impl(context, var_name, path, with_only_strings_str, with_full_yaml_features_str): # @DuplicatedSignature
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, with_only_strings_str is not None, with_full_yaml_features_str is not None)
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<with_only_strings_str> \(with only strings\))|(?P<with_full_yaml_features_str> \(with full YAML features\)))?")
47
- def step_impl(context, var_name, path, with_only_strings_str, with_full_yaml_features_str): # @DuplicatedSignature
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, with_only_strings_str is not None, with_full_yaml_features_str is not None)
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.save_file(data, path)
157
+ YAMLManager.restore_file(path, backup_extension=backup_extension)
61
158
 
62
159
 
63
160
 
@@ -0,0 +1,28 @@
1
+
2
+ #################################################
3
+ # HolAdo (Holistic Automation do)
4
+ #
5
+ # (C) Copyright 2021-2025 by Eric Klumpp
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
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
+ #################################################
13
+
14
+ from holado.common.handlers.enums import AutoNumber
15
+
16
+
17
+ class UpdateType(AutoNumber):
18
+ """
19
+ @summary: Update type
20
+ """
21
+
22
+ AddOrUpdate = () # Data are added (for all data types) or updated (for object or dict)
23
+ Replace = () # Leaf elements in data are replaced (for whole list or dict)
24
+ Delete = () # Leaf elements in data are deleted (value can be anything)
25
+
26
+
27
+
28
+