pyresttest
pyresttest copied to clipboard
define headers in config
I am trying to do this:
---
- config:
- testset: 'api test'
- variable_binds: {headers: {'lang': 'en','version': '1.0', ... }
- test:
- group: 'user api'
- name: 'test'
- url: '/profile'
- method: 'post'
- headers: {template: $headers}
- body: 'cover=cover'
- validators:
- compare: {jsonpath_ming: 'error', comparator: 'eq', expected: 0}
but
pyresttest/pyresttest/tests.py", line 207, in get_headers return dict(map(template_tuple, self._headers.items())) AttributeError: 'str' object has no attribute 'items'
how can do ?
Hi @esonger
I run in the same error, but I was trying to use a generator instead of a variable_binds.
I'm not sure if this will help, but I could setup header this way:
- config:`
- testset: "API Basic tests"
- generators:
- 'authgen': {type: 'authtime', uuid: abcde}
- variable_binds: {authid: '$auth_token'}
- test:
- group: "Test"
- name: "Teste header generator "
- url: "/api/v1/resource/"
- method: 'POST'
- expected_status: [200,201]
- generator_binds: {auth_token: authgen}
- headers: {template: {"X_AUTH": $auth_token}}
maybe you need to do the variable_bind in the test, not in config section
@claudiobastos 's solution worked for me. Althought the following is not needed. " - variable_binds: {authid: '$auth_token'}"