1

So, a brief description of what I want, what my issue is, and what I have tried.

  • I want to declare and use a dictionary variable for my tests in pyrest, specifically for the [url, body] section so that I can conduct my POST tests targeting a specific endpoint and with a preformatted body.

Here is how mytest.yml file is structured:

- data:
    - id: 63
    - rate: 25
    ... a sizable set of field for reasons ...
    - type: lab_test_authorization
    - modified_at: ansible_date_time.datetime  # Useful way to generate 

- test:
    - url: "some-valid-url/{the_url_question}" # data['special_key']
    - method: 'POST'
    - headers : {etc..etc}
    - body: '{ "data": ${the_body_question} }' # data (the content)
  • Now the problem starts in my lack of understanding why (if true) does pyrest does not have support for dictionary mappings. I understand yaml supports these feature but am not sure if pyrest can parse through it. Knowing how to call and use dictionary variable in my url and body tags would be significantly helpful.

  • As of right now, if I try to convert my data Sequence into a data Dictionary, I will get an error stating:

    yaml.parser.ParserError: while parsing a block mapping
      in "<unicode string>", line 4, column 1:
        data:
        ^
    expected <block end>, but found '-'
      in "<unicode string>", line 36, column 1:
        - config:
    

I'm pretty sure there are gaps in my knowledge regarding how yaml and pyresttest interact with each other, so any insight would be greatly appreciated.

archon263
  • 89
  • 1
  • 9
  • That's a YAML parser error, meaning that the data you provide is not valid YAML. However, it does not look like the error matches the YAML you show, since line and column numbers mismatch (eg `data:` does not start at column 1). It is unclear what you actually do with the YAML, please provide code. – flyx Oct 24 '18 at 08:33

0 Answers0