Skip to content

Commit 4b7c8f0

Browse files
committed
fix missed server->backend renaming
1 parent 009617d commit 4b7c8f0

File tree

13 files changed

+45
-51
lines changed

13 files changed

+45
-51
lines changed

src/idom/backend/fastapi.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66

77

88
serve_development_app = starlette.serve_development_app
9-
"""Alias for :func:`idom.server.starlette.serve_development_app`"""
9+
"""Alias for :func:`idom.backend.starlette.serve_development_app`"""
1010

1111
# see: https://github.com/idom-team/flake8-idom-hooks/issues/12
1212
use_location = starlette.use_location # noqa: ROH101
13-
"""Alias for :func:`idom.server.starlette.use_location`"""
13+
"""Alias for :func:`idom.backend.starlette.use_location`"""
1414

1515
# see: https://github.com/idom-team/flake8-idom-hooks/issues/12
1616
use_scope = starlette.use_scope # noqa: ROH101
17-
"""Alias for :func:`idom.server.starlette.use_scope`"""
17+
"""Alias for :func:`idom.backend.starlette.use_scope`"""
1818

1919
# see: https://github.com/idom-team/flake8-idom-hooks/issues/12
2020
use_websocket = starlette.use_websocket # noqa: ROH101
21-
"""Alias for :func:`idom.server.starlette.use_websocket`"""
21+
"""Alias for :func:`idom.backend.starlette.use_websocket`"""
2222

2323
Options = starlette.Options
24-
"""Alias for :class:`idom.server.starlette.Options`"""
24+
"""Alias for :class:`idom.backend.starlette.Options`"""
2525

2626
configure = starlette.configure
27-
"""Alias for :class:`idom.server.starlette.configure`"""
27+
"""Alias for :class:`idom.backend.starlette.configure`"""
2828

2929

3030
def create_development_app() -> FastAPI:

src/idom/backend/flask.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,12 @@
4545
def configure(
4646
app: Flask, component: RootComponentConstructor, options: Options | None = None
4747
) -> None:
48-
"""Return a :class:`FlaskServer` where each client has its own state.
49-
50-
Implements the :class:`~idom.server.proto.ServerFactory` protocol
48+
"""Configure the necessary IDOM routes on the given app.
5149
5250
Parameters:
53-
constructor: A component constructor
51+
app: An application instance
52+
component: A component constructor
5453
options: Options for configuring server behavior
55-
app: An application instance (otherwise a default instance is created)
5654
"""
5755
options = options or Options()
5856
blueprint = Blueprint("idom", __name__, url_prefix=options.url_prefix)

src/idom/backend/starlette.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ def configure(
4040
constructor: RootComponentConstructor,
4141
options: Options | None = None,
4242
) -> None:
43-
"""Return a :class:`StarletteServer` where each client has its own state.
44-
45-
Implements the :class:`~idom.server.proto.ServerFactory` protocol
43+
"""Configure the necessary IDOM routes on the given app.
4644
4745
Parameters:
4846
app: An application instance
49-
constructor: A component constructor
47+
component: A component constructor
5048
options: Options for configuring server behavior
5149
"""
5250
options = options or Options()

src/idom/backend/tornado.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ def configure(
3636
component: ComponentConstructor,
3737
options: Options | None = None,
3838
) -> None:
39-
"""Return a :class:`TornadoServer` where each client has its own state.
40-
41-
Implements the :class:`~idom.server.proto.ServerFactory` protocol
39+
"""Configure the necessary IDOM routes on the given app.
4240
4341
Parameters:
44-
app: A tornado ``Application`` instance.
45-
component: A root component constructor
46-
options: Options for configuring how the component is mounted to the server.
42+
app: An application instance
43+
component: A component constructor
44+
options: Options for configuring server behavior
4745
"""
4846
options = options or Options()
4947
_add_handler(

src/idom/backend/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def run(
4040
"Change this before deploying in production!"
4141
)
4242

43-
implementation = implementation or import_module("idom.server.default")
43+
implementation = implementation or import_module("idom.backend.default")
4444

4545
app = implementation.create_development_app()
4646
implementation.configure(app, component)

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

+10-10
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+
backend: BackendFixture | None = None,
2323
driver: Browser | BrowserContext | Page | None = None,
2424
) -> None:
25-
if server is not None:
26-
self.server = server
25+
if backend is not None:
26+
self.backend = backend
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()
@@ -57,9 +57,9 @@ async def __aenter__(self) -> DisplayFixture:
5757
browser = self._browser
5858
self.page = await browser.new_page()
5959

60-
if not hasattr(self, "server"):
61-
self.server = ServerFixture()
62-
await es.enter_async_context(self.server)
60+
if not hasattr(self, "backend"):
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

+5-5
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,8 +16,8 @@
1616
scope="module",
1717
)
1818
async def display(page, request):
19-
async with ServerFixture(implementation=request.param) as server:
20-
async with DisplayFixture(server=server, driver=page) as display:
19+
async with BackendFixture(implementation=request.param) as server:
20+
async with DisplayFixture(backend=server, driver=page) as display:
2121
yield display
2222

2323

@@ -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)