Skip to content

Commit 0c01945

Browse files
committed
Mkae commands testable
1 parent 22f317d commit 0c01945

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/fastcs/backends/rest/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def _wrap_command(
124124
method: Callable, controller: BaseController
125125
) -> Callable[..., Awaitable[None]]:
126126
async def command() -> None:
127-
await method.__get__(controller)()
127+
await getattr(controller, method.__name__)()
128128

129129
return command
130130

tests/backends/rest/test_rest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pytest
66
from fastapi.testclient import TestClient
77
from pytest_mock import MockerFixture
8-
from tests.conftest import AssertableController
98

109
from fastcs.attributes import AttrR
1110
from fastcs.backends.rest.backend import RestBackend
@@ -20,8 +19,8 @@ def pascal_2_snake(input: list[str]) -> list[str]:
2019

2120
class TestRestServer:
2221
@pytest.fixture(autouse=True)
23-
def setup_tests(self, mocker: MockerFixture):
24-
self.controller = AssertableController(mocker)
22+
def setup_tests(self, assertable_controller):
23+
self.controller = assertable_controller
2524
app = RestBackend(self.controller)._server._app
2625
self.client = TestClient(app)
2726

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ def controller():
143143
return TestController()
144144

145145

146+
@pytest.fixture
147+
def assertable_controller(mocker):
148+
return AssertableController(mocker)
149+
150+
146151
@pytest.fixture
147152
def mapping(controller):
148153
return Mapping(controller)

0 commit comments

Comments
 (0)