1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- # coding: utf-8
- from echod.forms import RequestForm, ResponseForm, MockForm
- def test_request_form():
- data = {
- 'body': {
- 'name': 'John Doe'
- },
- 'headers': {
- 'content_type': 'application/json',
- 'accept': 'application/json'
- }
- }
- form = RequestForm(data=data)
- assert form.validate()
- def test_response_form():
- data = {
- 'body': {
- 'name': 'John Doe'
- },
- 'headers': {
- 'content_type': 'application/json',
- 'accept': 'application/json'
- },
- 'status_code': 201,
- }
- form = ResponseForm(data=data)
- assert form.validate()
- def test_mock_form():
- data = {
- 'method': 'PUT',
- 'path': '/v1/users/',
- 'request': {
- 'body': {
- 'name': 'John Doe'
- },
- 'headers': {
- 'content_type': 'application/json',
- 'accept': 'application/json'
- }
- },
- 'response': {
- 'body': {
- 'name': 'John Doe'
- },
- 'headers': {
- 'content_type': 'application/json',
- 'accept': 'application/json'
- },
- 'status_code': 201,
- }
- }
- form = MockForm(data=data)
- assert form.validate()
- def test_mock_form_without_request():
- data = {
- 'method': 'PUT',
- 'path': '/v1/users/',
- 'response': {
- 'body': {
- 'name': 'John Doe'
- },
- 'headers': {
- 'content_type': 'application/json',
- 'accept': 'application/json'
- },
- 'status_code': 201,
- }
- }
- form = MockForm(data=data)
- assert form.validate()
|