Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Support for in-process WSGI apps testing #283

Merged
merged 1 commit into from Dec 12, 2019
Merged

Conversation

svtkachenko
Copy link
Contributor

@svtkachenko svtkachenko commented Nov 18, 2019

Closes #31

TODO:

  • Add more test cases for validate_app
  • Fix coverage
  • Test with multiple workers (probably it could be extra parametrization level)
  • Make flask server behave in the same way as aiohttp one (the same port, args, etc). add CLI option to test_server.sh
  • catch output from the application - it should not mess the CLI, not it just appears among other symbols. should be in a separate section
  • fix mypy on CI
  • Do not display App in the CLI error output
  • Display proper reproduction code - it should be werkzeug, not requests - POSTPONED
  • refactor runner - code for WSGI apps should not create requests.Session
  • handle Auth & headers in runner properly - they should be propagated to the werkzeug client
  • checks should receive Union[requests.Response, WSGIResponse] or some another class that will provide consistent behavior + verify that all check works
  • Handle 404 in from_wsgi
  • Docs

@svtkachenko svtkachenko changed the title Schema loader for WSGI apps [WIP] Schema loader for WSGI apps Nov 18, 2019
pyproject.toml Outdated Show resolved Hide resolved
src/schemathesis/loaders.py Outdated Show resolved Hide resolved
src/schemathesis/loaders.py Outdated Show resolved Hide resolved
src/schemathesis/models.py Outdated Show resolved Hide resolved
src/schemathesis/schemas.py Outdated Show resolved Hide resolved
@Stranger6667 Stranger6667 dismissed their stale review November 30, 2019 14:53

I will continue this PR

@codecov-io
Copy link

codecov-io commented Nov 30, 2019

Codecov Report

Merging #283 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #283      +/-   ##
==========================================
+ Coverage   99.92%   99.93%   +<.01%     
==========================================
  Files          22       22              
  Lines        1385     1536     +151     
  Branches      222      248      +26     
==========================================
+ Hits         1384     1535     +151     
  Partials        1        1
Flag Coverage Δ
#unittests 99.93% <100%> (ø) ⬆️
Impacted Files Coverage Δ
src/schemathesis/_hypothesis.py 100% <ø> (ø) ⬆️
src/schemathesis/__init__.py 100% <100%> (ø) ⬆️
src/schemathesis/runner/checks.py 100% <100%> (ø) ⬆️
src/schemathesis/cli/__init__.py 100% <100%> (ø) ⬆️
src/schemathesis/loaders.py 100% <100%> (ø) ⬆️
src/schemathesis/schemas.py 100% <100%> (ø) ⬆️
src/schemathesis/cli/output/default.py 99.49% <100%> (+0.04%) ⬆️
src/schemathesis/exceptions.py 100% <100%> (ø) ⬆️
src/schemathesis/utils.py 100% <100%> (ø) ⬆️
src/schemathesis/cli/callbacks.py 100% <100%> (ø) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f395d5...ce67335. Read the comment docs.

@Stranger6667 Stranger6667 self-assigned this Dec 11, 2019
@Stranger6667 Stranger6667 changed the title [WIP] Schema loader for WSGI apps [WIP] Support for in-process WSGI apps testing Dec 11, 2019
@@ -60,8 +64,12 @@ def response_schema_conformance(response: requests.Response, result: TestResult)
schema = definition.get("schema")
if not schema:
return
if isinstance(response, requests.Response):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it will be better to provide some kind of abstraction so code in checks will be unified

if framework == "aiohttp":
app = _aiohttp.create_app(prepared_endpoints)
web.run_app(app, port=port)
elif framework == "flask":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be nice to test Django as well - maybe in a separate PR

test/test_models.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test case executor for WSGI apps
3 participants