-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mapping protocol for schemas & direct access to endpoint strategies. C…
…loses #98
- Loading branch information
1 parent
f8f23d3
commit c3482a5
Showing
6 changed files
with
110 additions
and
4 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
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,39 @@ | ||
import hypothesis.strategies as st | ||
|
||
from schemathesis.models import Case, Endpoint | ||
|
||
|
||
def test_contains(swagger_20): | ||
assert "/v1/users" in swagger_20 | ||
|
||
|
||
def test_getitem(swagger_20): | ||
assert "_endpoints" not in swagger_20.__dict__ | ||
assert isinstance(swagger_20["/v1/users"], dict) | ||
# Check cached access | ||
assert "_endpoints" in swagger_20.__dict__ | ||
assert isinstance(swagger_20["/v1/users"], dict) | ||
|
||
|
||
def test_len(swagger_20): | ||
assert len(swagger_20) == 1 | ||
|
||
|
||
def test_iter(swagger_20): | ||
assert list(swagger_20) == ["/v1/users"] | ||
|
||
|
||
def test_repr(swagger_20): | ||
assert str(swagger_20) == "SwaggerV20 for Sample API (1.0.0)" | ||
|
||
|
||
def test_endpoint_access(swagger_20): | ||
assert isinstance(swagger_20["/v1/users"]["GET"], Endpoint) | ||
|
||
|
||
def test_as_strategy(swagger_20): | ||
strategy = swagger_20["/v1/users"]["GET"].as_strategy() | ||
assert isinstance(strategy, st.SearchStrategy) | ||
assert strategy.example() == Case( | ||
path="/v1/users", method="GET", path_parameters={}, headers={}, cookies={}, query={}, body={}, form_data={} | ||
) |