What are the YAML keywords that can be used in RobotFramework for editing YAML file?

Viewed 556

I tried editing YAML file and I came across only few keywords that can be used for editing dictionary values of YAML file. But I need to edit list values in YAML file as well. So, where can I get all the keywords list which can be used for editing YAML file using robot framework?

Example: 1. Below is the sample YAML file

"patch_id_bw_data":
    "pronghornResponseBody":
        "shimBehaviourHeader":
            "destinationURL": ""
            "method": "PATCH"
            "targetName": "naas"
        "customHeaders": {}
        "responseBody":
            - "op": "replace"
              "path": "/serviceCharacteristic"
              "value":
                  - "name": "bandwidth"
                    "value": ""
  1. Here is the code for editing dictionary values. Same I want to do for list as well.
*** Settings ***
Library  yaml
Library  OperatingSystem
Library  Collections

*** Test Cases ***
Load YAML into Robot and edit it
  ${YAML}=  Get File  ${CURDIR}${/}data.yaml
  ${LOADED}=  yaml.Safe Load  ${YAML}
  Set To Dictionary  ${LOADED}[patch_id_bw_data][pronghornResponseBody][responseBody][0][value][0]  value=200
  ${OUTPUT}=  yaml.Dump  ${LOADED}
  Create File  newdata.yaml  ${OUTPUT}
1 Answers

"Set List Value", per The Collections Library Documentation. You're not really editing YAML. Rather, you're modifying a collection that happened to have been read from a YAML file. Refer to the docs for other manipulations you can perform on collections.

Related