Skip to content

Commit c92079a

Browse files
committed
test_standalone
1 parent f7b15f4 commit c92079a

File tree

4 files changed

+15
-157
lines changed

4 files changed

+15
-157
lines changed
File renamed without changes.

tests/test_backend/test_all.py renamed to tests/test_asgi/test_standalone.py

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,15 @@
44

55
import reactpy
66
from reactpy import html
7-
from reactpy.asgi import default as default_implementation
8-
from reactpy.asgi._common import PATH_PREFIX
9-
from reactpy.asgi.utils import all_implementations
7+
from reactpy.asgi.standalone import ReactPy
108
from reactpy.testing import BackendFixture, DisplayFixture, poll
11-
from reactpy.types import BackendType, Connection, Location
9+
from reactpy.types import Connection, Location
1210

1311

14-
@pytest.fixture(
15-
params=[*list(all_implementations()), default_implementation],
16-
ids=lambda imp: imp.__name__,
17-
)
12+
@pytest.fixture()
1813
async def display(page, request):
19-
imp: BackendType = request.param
20-
21-
# we do this to check that route priorities for each backend are correct
22-
if imp is default_implementation:
23-
url_prefix = ""
24-
opts = None
25-
else:
26-
url_prefix = str(PATH_PREFIX)
27-
opts = imp.Options(url_prefix=url_prefix)
28-
29-
async with BackendFixture(implementation=imp, options=opts) as server:
30-
async with DisplayFixture(
31-
backend=server,
32-
driver=page,
33-
url_prefix=url_prefix,
34-
) as display:
14+
async with BackendFixture() as server:
15+
async with DisplayFixture(backend=server, driver=page) as display:
3516
yield display
3617

3718

@@ -128,17 +109,12 @@ def ShowRoute():
128109
await poll_location.until_equals(loc)
129110

130111

131-
@pytest.mark.parametrize("hook_name", ["use_request", "use_websocket"])
132-
async def test_use_request(display: DisplayFixture, hook_name):
133-
hook = getattr(display.backend.implementation, hook_name, None)
134-
if hook is None:
135-
pytest.skip(f"{display.backend.implementation} has no '{hook_name}' hook")
136-
112+
async def test_carrier(display: DisplayFixture):
137113
hook_val = reactpy.Ref()
138114

139115
@reactpy.component
140116
def ShowRoute():
141-
hook_val.current = hook()
117+
hook_val.current = reactpy.hooks.use_connection().carrier
142118
return html.pre({"id": "hook"}, str(hook_val.current))
143119

144120
await display.show(ShowRoute)
@@ -149,18 +125,16 @@ def ShowRoute():
149125
assert hook_val.current is not None
150126

151127

152-
@pytest.mark.parametrize("imp", all_implementations())
153-
async def test_customized_head(imp: BackendType, page):
154-
custom_title = f"Custom Title for {imp.__name__}"
128+
async def test_customized_head(page):
129+
custom_title = "Custom Title for ReactPy"
155130

156131
@reactpy.component
157132
def sample():
158133
return html.h1(f"^ Page title is customized to: '{custom_title}'")
159134

160-
async with BackendFixture(
161-
implementation=imp,
162-
options=imp.Options(head=html.title(custom_title)),
163-
) as server:
164-
async with DisplayFixture(backend=server, driver=page) as display:
165-
await display.show(sample)
166-
assert (await display.page.title()) == custom_title
135+
app = ReactPy(sample, html_head=html.head(html.title(custom_title)))
136+
137+
async with BackendFixture(app) as server:
138+
async with DisplayFixture(backend=server, driver=page) as new_display:
139+
await new_display.show(sample)
140+
assert (await new_display.page.title()) == custom_title

tests/test_backend/test_common.py

Lines changed: 0 additions & 70 deletions
This file was deleted.

tests/test_backend/test_utils.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)