-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
require a magic response for dev reload server to reconnect (#115)
- Loading branch information
1 parent
4274a8d
commit 429275b
Showing
3 changed files
with
34 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from unittest.mock import patch | ||
|
||
from fastui.dev import dev_fastapi_app | ||
from httpx import AsyncClient | ||
|
||
|
||
def mock_signal(_sig, on_signal): | ||
on_signal() | ||
|
||
|
||
async def test_dev_connect(): | ||
with patch('fastui.dev.signal.signal', new=mock_signal): | ||
app = dev_fastapi_app() | ||
async with app.router.lifespan_context(app): | ||
async with AsyncClient(app=app, base_url='http://test') as client: | ||
r = await client.get('/api/__dev__/reload') | ||
assert r.status_code == 200 | ||
assert r.headers['content-type'] == 'text/plain; charset=utf-8' | ||
assert r.text.startswith('fastui-dev-reload\n') |