Commit Graph

12 Commits

Author SHA1 Message Date
Daniel Hahler 6902361c98
test_database_execute_many: remove unnecessary statement (#778)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2021-09-18 14:10:40 +02:00
Thomas Grainger d222b87cb4
TestClient accepts backend and backend_options as arguments to constructor (#1211)
as opposed to ClassVar assignment 

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
Co-authored-by: Jordan Speicher <jordan@jspeicher.com>
Co-authored-by: Jordan Speicher <uSpike@users.noreply.github.com>
2021-06-28 21:36:13 +01:00
Jordan Speicher 42592d68e5
anyio integration (#1157)
* First whack at anyio integration

* Fix formatting

* Remove debug messages

* mypy fixes

* Update README.md

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>

* Fix install_requires typo

* move_on_after blocks if deadline is too small

* Linter fixes

* Improve WSGI structured concurrency

* Tests use anyio

* Checkin progress on testclient

* Prep for anyio 3

* Remove debug backend option

* Use anyio 3.0.0rc1

* Remove old style executor from GraphQLApp

* Fix extra import

* Don't cancel task scope early

* Wait for wsgi sender to finish before exiting

* Use memory object streams in websocket tests

* Test on asyncio, asyncio+uvloop, and trio

* Formatting fixes

* run_until_first_complete doesn't need a return

* Fix middleware app call

* Simplify middleware exceptions

* Use anyio for websocket test

* Set STARLETTE_TESTCLIENT_ASYNC_BACKEND in tests

* Pass async backend to portal

* Formatting fixes

* Bump anyio

* Cleanup portals and add TestClient.async_backend

* Use anyio.run_async_from_thread to send from worker thread

* Use websocket_connect as context manager

* Document changes in TestClient

* Formatting fix

* Fix websocket raises coverage

* Update to anyio 3.0.0rc3 and replace aiofiles

* Apply suggestions from code review

Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>

* Bump to require anyio 3.0.0 final

* Remove mention of aiofiles in README.md

* Pin jinja2 to releases before 3 due to DeprecationWarnings

* Add task_group as application attribute

* Remove run_until_first_complete

* Undo jinja pin

* Refactor anyio.sleep into an event

* Use one less task in test_websocket_concurrency_pattern

* Apply review suggestions

* Rename argument

* fix start_task_soon type

* fix BaseHTTPMiddleware when used without Starlette

* Testclient receive() is a non-trapping function if the response is already complete

This allows for a zero deadline when waiting for a disconnect message

* Use variable annotation for async_backend

* Update docs regarding dependency on anyio

* Use CancelScope instead of move_on_after in request.is_disconnected

* Cancel task group after returning middleware response

Add test for https://github.com/encode/starlette/issues/1022

* Add link to anyio backend options in testclient docs

* Add types-dataclasses

* Re-implement starlette.concurrency.run_until_first_complete and add a test

* Fix type on handler callable

* Apply review comments to clarify run_until_first_complete scope

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2021-06-18 15:48:43 +01:00
Daniel Hahler e0e2621add flake8 fixes (#512) 2019-05-13 15:22:59 +01:00
Tom Christie e396f079a5
Version 0.11 (#402)
* Add Mount(routes=...)

* Lifespan route instance

* Lifespan as a standard routing component

* Linting

* Linting

* Version 0.10.6

* Release notes

* Version 0.11.0

* Drop redundant import

* Drop redundant database requirements

* Include htmlcov in scripts/clean

* Drop redundant import

* Release notes

* Linting
2019-02-19 12:54:57 +00:00
Santiago abf7f1ccf9 fix: jinja annotations when jinja not installed (#399) 2019-02-18 18:29:30 +00:00
Tom Christie b3ad311bbc
Template component (#398)
* Add Jinja2Templates component

* Fix imports

* Prevent code formatters from moving deliberatly late import
2019-02-18 13:28:18 +00:00
Tom Christie e8dff17ed4
Move to 'databases' instead of built-in DatabaseMiddleware (#390) 2019-02-14 16:01:51 +00:00
Tom Christie 3270762c16
MySQL driver support (#366)
* initial support for MySQL

* Work towards testing both MySQL and Postgres drivers

* Linting

* STARLETTE_TEST_DATABASE -> STARLETTE_TEST_DATABASES

* Parameterize the database tests

* Include the MySQL Database URL

* MySQL tests should create the database if it doesn't yet exist

* Explict port of MySQL database URL

* Debugging on Travis

* Pass 'args' as a single argument

* Fix query compilation for mysql

* Lookup record values for MySQL

* Coerce MySQL results to correct python_type

* cursor.fetchrow should be cursor.fetchone

* Fix call to cursor.fetchone()

* Fix for fetchval()

* Debugging

* Nested transaction for MySQL should use SAVEPOINTS

* Drop savepoint implementation

* Fix SAVEPOINT implementation for MySQL

* Coverage for MySQL

* Linting

* Tweak defaults for MySQL connections
2019-01-30 14:21:58 +00:00
Daniel Hahler d978bd4eef tests: skip test_database without DATABASE_URL (#263)
* tests: skip test_database without DATABASE_URL

(instead of causing a collection error)

* fixup! tests: skip test_database without DATABASE_URL
2018-12-11 13:09:09 +00:00
Tom Christie 1e1f3bab46
Add executemany (#259) 2018-12-10 14:37:30 +00:00
Tom Christie 0b7819b4b2
Add DatabaseMiddleware (#243)
* Add `DatabaseMiddleware`
2018-12-04 16:05:16 +00:00