Skip to content

Commit 094b1a1

Browse files
committed
more renaming of server to backend
1 parent 595bed4 commit 094b1a1

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

src/idom/testing/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from .backend import BackendFixture
12
from .common import HookCatcher, StaticEventHandler, clear_idom_web_modules_dir, poll
23
from .display import DisplayFixture
34
from .logs import (
@@ -6,7 +7,6 @@
67
assert_idom_did_not_log,
78
capture_idom_logs,
89
)
9-
from .server import ServerFixture
1010

1111

1212
__all__ = [
@@ -18,6 +18,6 @@
1818
"HookCatcher",
1919
"LogAssertionError",
2020
"poll",
21-
"ServerFixture",
21+
"BackendFixture",
2222
"StaticEventHandler",
2323
]

src/idom/testing/server.py renamed to src/idom/testing/backend.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
from .logs import LogAssertionError, capture_idom_logs, list_logged_exceptions
1616

1717

18-
class ServerFixture:
18+
class BackendFixture:
1919
"""A test fixture for running a server and imperatively displaying views
2020
2121
This fixture is typically used alongside async web drivers like ``playwight``.
2222
2323
Example:
2424
.. code-block::
2525
26-
async with ServerFixture() as server:
26+
async with BackendFixture() as server:
2727
server.mount(MyComponent)
2828
"""
2929

@@ -99,7 +99,7 @@ def list_logged_exceptions(
9999
del_log_records,
100100
)
101101

102-
async def __aenter__(self) -> ServerFixture:
102+
async def __aenter__(self) -> BackendFixture:
103103
self._exit_stack = AsyncExitStack()
104104
self._records = self._exit_stack.enter_context(capture_idom_logs())
105105

src/idom/testing/display.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from idom import html
1010
from idom.types import RootComponentConstructor
1111

12-
from .server import ServerFixture
12+
from .backend import BackendFixture
1313

1414

1515
class DisplayFixture:
@@ -19,11 +19,11 @@ class DisplayFixture:
1919

2020
def __init__(
2121
self,
22-
server: ServerFixture | None = None,
22+
server: BackendFixture | None = None,
2323
driver: Browser | BrowserContext | Page | None = None,
2424
) -> None:
2525
if server is not None:
26-
self.server = server
26+
self.backend = server
2727
if driver is not None:
2828
if isinstance(driver, Page):
2929
self.page = driver
@@ -37,13 +37,13 @@ async def show(
3737
) -> None:
3838
self._next_view_id += 1
3939
view_id = f"display-{self._next_view_id}"
40-
self.server.mount(lambda: html.div({"id": view_id}, component()))
40+
self.backend.mount(lambda: html.div({"id": view_id}, component()))
4141

4242
await self.goto("/")
4343
await self.page.wait_for_selector(f"#{view_id}", state="attached")
4444

4545
async def goto(self, path: str, query: Any | None = None) -> None:
46-
await self.page.goto(self.server.url(path, query))
46+
await self.page.goto(self.backend.url(path, query))
4747

4848
async def __aenter__(self) -> DisplayFixture:
4949
es = self._exit_stack = AsyncExitStack()
@@ -58,8 +58,8 @@ async def __aenter__(self) -> DisplayFixture:
5858
self.page = await browser.new_page()
5959

6060
if not hasattr(self, "server"):
61-
self.server = ServerFixture()
62-
await es.enter_async_context(self.server)
61+
self.backend = BackendFixture()
62+
await es.enter_async_context(self.backend)
6363

6464
return self
6565

@@ -69,5 +69,5 @@ async def __aexit__(
6969
exc_value: BaseException | None,
7070
traceback: TracebackType | None,
7171
) -> None:
72-
self.server.mount(None)
72+
self.backend.mount(None)
7373
await self._exit_stack.aclose()

tests/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
from idom.config import IDOM_TESTING_DEFAULT_TIMEOUT
1111
from idom.testing import (
12+
BackendFixture,
1213
DisplayFixture,
13-
ServerFixture,
1414
capture_idom_logs,
1515
clear_idom_web_modules_dir,
1616
)
@@ -34,7 +34,7 @@ async def display(server, page):
3434

3535
@pytest.fixture(scope="session")
3636
async def server():
37-
async with ServerFixture() as server:
37+
async with BackendFixture() as server:
3838
yield server
3939

4040

tests/test_client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from playwright.async_api import Browser
66

77
import idom
8-
from idom.testing import DisplayFixture, ServerFixture
8+
from idom.testing import BackendFixture, DisplayFixture
99

1010

1111
JS_DIR = Path(__file__).parent / "js"
@@ -22,7 +22,7 @@ def OldComponent():
2222
return idom.html.p({"id": "old-component"}, "old")
2323

2424
async with AsyncExitStack() as exit_stack:
25-
server = await exit_stack.enter_async_context(ServerFixture(port=8000))
25+
server = await exit_stack.enter_async_context(BackendFixture(port=8000))
2626
display = await exit_stack.enter_async_context(
2727
DisplayFixture(server, driver=page)
2828
)
@@ -43,7 +43,7 @@ def NewComponent():
4343
return idom.html.p({"id": f"new-component-{state}"}, f"new-{state}")
4444

4545
async with AsyncExitStack() as exit_stack:
46-
server = await exit_stack.enter_async_context(ServerFixture(port=8000))
46+
server = await exit_stack.enter_async_context(BackendFixture(port=8000))
4747
display = await exit_stack.enter_async_context(
4848
DisplayFixture(server, driver=page)
4949
)

tests/test_server/test_common.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from idom.backend import default as default_implementation
88
from idom.backend.types import Location
99
from idom.backend.utils import all_implementations
10-
from idom.testing import DisplayFixture, ServerFixture, poll
10+
from idom.testing import BackendFixture, DisplayFixture, poll
1111

1212

1313
@pytest.fixture(
@@ -16,7 +16,7 @@
1616
scope="module",
1717
)
1818
async def display(page, request):
19-
async with ServerFixture(implementation=request.param) as server:
19+
async with BackendFixture(implementation=request.param) as server:
2020
async with DisplayFixture(server=server, driver=page) as display:
2121
yield display
2222

@@ -69,7 +69,7 @@ async def test_use_scope(display: DisplayFixture):
6969

7070
@idom.component
7171
def ShowScope():
72-
scope.current = display.server.implementation.use_scope()
72+
scope.current = display.backend.implementation.use_scope()
7373
return html.pre({"id": "scope"}, str(scope.current))
7474

7575
await display.show(ShowScope)
@@ -88,7 +88,7 @@ async def poll_location():
8888

8989
@idom.component
9090
def ShowRoute():
91-
location.current = display.server.implementation.use_location()
91+
location.current = display.backend.implementation.use_location()
9292
return html.pre({"id": "scope"}, str(location.current))
9393

9494
await display.show(ShowRoute)

tests/test_testing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ def test_if_app_is_given_implementation_must_be_too():
141141
ValueError,
142142
match=r"If an application instance its corresponding server implementation must be provided too",
143143
):
144-
testing.ServerFixture(app=starlette_implementation.create_development_app())
144+
testing.BackendFixture(app=starlette_implementation.create_development_app())
145145

146-
testing.ServerFixture(
146+
testing.BackendFixture(
147147
app=starlette_implementation.create_development_app(),
148148
implementation=starlette_implementation,
149149
)

tests/test_web/test_module.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import idom
77
from idom.backend import sanic as sanic_implementation
88
from idom.testing import (
9+
BackendFixture,
910
DisplayFixture,
10-
ServerFixture,
1111
assert_idom_did_log,
1212
assert_idom_did_not_log,
1313
poll,
@@ -70,7 +70,7 @@ async def test_module_from_url(browser):
7070
def ShowSimpleButton():
7171
return SimpleButton({"id": "my-button"})
7272

73-
async with ServerFixture(app=app, implementation=sanic_implementation) as server:
73+
async with BackendFixture(app=app, implementation=sanic_implementation) as server:
7474
async with DisplayFixture(server, browser) as display:
7575
await display.show(ShowSimpleButton)
7676

0 commit comments

Comments
 (0)