1010from starlette .routing import Route
1111from starlette .templating import Jinja2Templates
1212
13- import reactpy
13+ from reactpy import config as _config
1414from reactpy import html
1515from reactpy .executors .asgi .pyscript import ReactPyCsr
1616from reactpy .testing import BackendFixture , DisplayFixture
17- from reactpy .testing .common import REACTPY_TESTS_DEFAULT_TIMEOUT
17+
18+ REACTPY_TESTS_DEFAULT_TIMEOUT = _config .REACTPY_TESTS_DEFAULT_TIMEOUT
1819
1920
2021@pytest .fixture (scope = "module" )
@@ -106,77 +107,12 @@ def test_bad_file_path():
106107 ReactPyCsr ()
107108
108109
109- async def test_customized_noscript (tmp_path : Path ):
110- noscript_file = tmp_path / "noscript.html"
111- noscript_file .write_text (
112- '<p id="noscript-message">Please enable JavaScript.</p>' ,
113- encoding = "utf-8" ,
114- )
115-
116- app = ReactPyCsr (
117- Path (__file__ ).parent / "pyscript_components" / "root.py" ,
118- html_noscript = noscript_file ,
119- )
120-
121- async with BackendFixture (app ) as server :
122- url = f"http://{ server .host } :{ server .port } "
123- response = await asyncio .to_thread (
124- request , "GET" , url , timeout = REACTPY_TESTS_DEFAULT_TIMEOUT .current
125- )
126- assert response .status_code == 200
127- assert (
128- '<noscript><p id="noscript-message">Please enable JavaScript.</p></noscript>'
129- in response .text
130- )
131-
132-
133-
134- async def test_customized_noscript_string ():
135- app = ReactPyCsr (
136- Path (__file__ ).parent / "pyscript_components" / "root.py" ,
137- html_noscript = '<p id="noscript-message">Please enable JavaScript.</p>' ,
138- )
139-
140- async with BackendFixture (app ) as server :
141- url = f"http://{ server .host } :{ server .port } "
142- response = await asyncio .to_thread (
143- request , "GET" , url , timeout = REACTPY_TESTS_DEFAULT_TIMEOUT .current
144- )
145- assert response .status_code == 200
146- assert (
147- '<noscript><p id="noscript-message">Please enable JavaScript.</p></noscript>'
148- in response .text
149- )
150-
151-
152- async def test_customized_noscript_from_file (tmp_path : Path ):
153- noscript_file = tmp_path / "noscript.html"
154- noscript_file .write_text (
155- '<p id="noscript-message">Please enable JavaScript.</p>' ,
156- encoding = "utf-8" ,
157- )
158-
159- app = ReactPyCsr (
160- Path (__file__ ).parent / "pyscript_components" / "root.py" ,
161- html_noscript = noscript_file ,
162- )
163-
164- async with BackendFixture (app ) as server :
165- url = f"http://{ server .host } :{ server .port } "
166- response = await asyncio .to_thread (
167- request , "GET" , url , timeout = REACTPY_TESTS_DEFAULT_TIMEOUT .current
168- )
169- assert response .status_code == 200
170- assert (
171- '<noscript><p id="noscript-message">Please enable JavaScript.</p></noscript>'
172- in response .text
173- )
174-
175-
176- async def test_customized_noscript_from_string ():
110+ async def test_customized_noscript_vdom ():
177111 app = ReactPyCsr (
178112 Path (__file__ ).parent / "pyscript_components" / "root.py" ,
179- html_noscript = '<p id="noscript-message">Please enable JavaScript.</p>' ,
113+ prepend_body = html .noscript (
114+ html .p ({"id" : "noscript-message" }, "Please enable JavaScript." )
115+ ),
180116 )
181117
182118 async with BackendFixture (app ) as server :
@@ -190,17 +126,6 @@ async def test_customized_noscript_from_string():
190126 in response .text
191127 )
192128
193-
194- async def test_customized_noscript_from_component ():
195- @reactpy .component
196- def noscript_message ():
197- return html .p ({"id" : "noscript-message" }, "Please enable JavaScript." )
198-
199- app = ReactPyCsr (
200- Path (__file__ ).parent / "pyscript_components" / "root.py" ,
201- html_noscript = noscript_message ,
202- )
203-
204129 async with BackendFixture (app ) as server :
205130 url = f"http://{ server .host } :{ server .port } "
206131 response = await asyncio .to_thread (
@@ -213,20 +138,7 @@ def noscript_message():
213138 )
214139
215140
216- async def test_default_noscript_rendered ():
217- app = ReactPyCsr (Path (__file__ ).parent / "pyscript_components" / "root.py" )
218-
219- async with BackendFixture (app ) as server :
220- url = f"http://{ server .host } :{ server .port } "
221- response = await asyncio .to_thread (
222- request , "GET" , url , timeout = REACTPY_TESTS_DEFAULT_TIMEOUT .current
223- )
224- assert response .status_code == 200
225- assert "<noscript>Enable JavaScript to view this site.</noscript>" in response .text
226-
227-
228-
229- async def test_noscript_omitted ():
141+ async def test_prepend_body_default_is_noscript ():
230142 app = ReactPyCsr (Path (__file__ ).parent / "pyscript_components" / "root.py" )
231143
232144 async with BackendFixture (app ) as server :
@@ -236,15 +148,14 @@ async def test_noscript_omitted():
236148 )
237149 assert response .status_code == 200
238150 assert (
239- "<noscript>Enable JavaScript to view this site.</noscript>"
240- in response .text
151+ "<noscript>Enable JavaScript to view this site.</noscript>" in response .text
241152 )
242153
243154
244- async def test_noscript_disabled ():
155+ async def test_prepend_body_disabled ():
245156 app = ReactPyCsr (
246157 Path (__file__ ).parent / "pyscript_components" / "root.py" ,
247- html_noscript = None ,
158+ prepend_body = None ,
248159 )
249160
250161 async with BackendFixture (app ) as server :
0 commit comments