-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
99 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ sphinx==2.4.1 | |
sphinx_rtd_theme | ||
pytest-html==2.0.1 | ||
coverage==5.0.3 | ||
hypothesis==5.10.4 |
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,25 @@ | ||
import argparse | ||
|
||
import pytest | ||
from hypothesis import given, strategies as st | ||
|
||
from apifuzzer.utils import json_data | ||
from test.unit_test_composer import dict_str, list_of_dicts | ||
|
||
|
||
@given(st.text(min_size=1)) | ||
def test_json_data_invalid(data): | ||
with pytest.raises(argparse.ArgumentTypeError): | ||
json_data(data) | ||
|
||
|
||
@given(data=dict_str()) | ||
def test_json_data_dict_valid(data): | ||
res = json_data(data) | ||
assert isinstance(res, dict) | ||
|
||
|
||
@given(data=list_of_dicts()) | ||
def test_json_data_list_valid(data): | ||
res = json_data(data) | ||
assert isinstance(res, list) |
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,11 @@ | ||
from hypothesis import strategies as st | ||
|
||
|
||
@st.composite | ||
def dict_str(draw): | ||
return draw(st.dictionaries(st.text(min_size=1), st.text(min_size=1), min_size=1)) | ||
|
||
|
||
@st.composite | ||
def list_of_dicts(draw): | ||
return draw(st.lists(dict_str())) |