forked from Trax-air/swagger-tester
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mild-blue/improve-reporting
Support scalar type definitions
- Loading branch information
Showing
6 changed files
with
87 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
swagger: '2.0' | ||
info: | ||
version: '2016-01-19T11:24:50Z' | ||
title: authentication tests | ||
schemes: | ||
- http | ||
paths: | ||
/test: | ||
get: | ||
description: Get something | ||
responses: | ||
'200': | ||
description: OK | ||
schema: | ||
$ref: '#/definitions/my_enum' | ||
definitions: | ||
my_enum: | ||
type: string | ||
enum: | ||
- OPTION_A | ||
- OPTION_B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding:utf-8 -*- | ||
import pytest | ||
|
||
from swagger_unittest.swagger_tester import swagger_tester | ||
|
||
|
||
def test_validate_definition(swagger_parser, pet_definition_example): | ||
valid_response = swagger_parser.definitions_example['Pet'] | ||
|
||
# Valid Pet is valid definition | ||
swagger_tester.validate_definition(swagger_parser, valid_response, valid_response) | ||
|
||
# Changing list with emtpy list is valid definition of Pet | ||
response = valid_response.copy() | ||
assert len(response['tags']) > 0 | ||
response['tags'] = [] | ||
swagger_tester.validate_definition(swagger_parser, valid_response, response) | ||
|
||
# Changing list with string is not valid definition of Pet | ||
with pytest.raises(AssertionError): | ||
response = valid_response.copy() | ||
response['tags'] = 'foo' | ||
swagger_tester.validate_definition(swagger_parser, valid_response, response) | ||
|
||
# Empty dict is not valid Pet | ||
with pytest.raises(AssertionError, match=r".*Responses are not compatible\. Definition of valid response is.*"): | ||
swagger_tester.validate_definition(swagger_parser, valid_response, {}) |