|
16 | 16 |
|
17 | 17 |
|
18 | 18 | @pytest.fixture
|
19 |
| -def async_client_setup(mocker: MockerFixture) -> AsyncClient: |
| 19 | +def mocked_session(mocker: MockerFixture): |
20 | 20 | session = mocker.MagicMock()
|
21 |
| - mock_response(session) |
22 |
| - client = AsyncClient(session=session, bucket="mybucket") |
| 21 | + session.dry_mode = False |
| 22 | + return session |
| 23 | + |
| 24 | + |
| 25 | +@pytest.fixture |
| 26 | +def async_client_setup(mocked_session, mocker: MockerFixture) -> AsyncClient: |
| 27 | + mock_response(mocked_session) |
| 28 | + client = AsyncClient(session=mocked_session, bucket="mybucket") |
23 | 29 | return client
|
24 | 30 |
|
25 | 31 |
|
26 | 32 | @pytest.fixture
|
27 |
| -def client_setup(mocker: MockerFixture) -> Client: |
28 |
| - session = mocker.MagicMock() |
29 |
| - mock_response(session) |
30 |
| - client = Client(session=session, bucket="mybucket") |
| 33 | +def client_setup(mocked_session, mocker: MockerFixture) -> Client: |
| 34 | + mock_response(mocked_session) |
| 35 | + client = Client(session=mocked_session, bucket="mybucket") |
31 | 36 | return client
|
32 | 37 |
|
33 | 38 |
|
34 | 39 | @pytest.fixture
|
35 |
| -def record_async_setup(mocker: MockerFixture) -> AsyncClient: |
36 |
| - session = mocker.MagicMock() |
37 |
| - session.request.return_value = (mocker.sentinel.response, mocker.sentinel.count) |
38 |
| - client = AsyncClient(session=session, bucket="mybucket", collection="mycollection") |
| 40 | +def record_async_setup(mocked_session, mocker: MockerFixture) -> AsyncClient: |
| 41 | + mocked_session.request.return_value = (mocker.sentinel.response, mocker.sentinel.count) |
| 42 | + client = AsyncClient(session=mocked_session, bucket="mybucket", collection="mycollection") |
39 | 43 | return client
|
40 | 44 |
|
41 | 45 |
|
42 | 46 | @pytest.fixture
|
43 |
| -def record_setup(mocker: MockerFixture) -> Client: |
44 |
| - session = mocker.MagicMock() |
45 |
| - session.request.return_value = (mocker.sentinel.response, mocker.sentinel.count) |
46 |
| - client = Client(session=session, bucket="mybucket", collection="mycollection") |
| 47 | +def record_setup(mocked_session, mocker: MockerFixture) -> Client: |
| 48 | + mocked_session.request.return_value = (mocker.sentinel.response, mocker.sentinel.count) |
| 49 | + client = Client(session=mocked_session, bucket="mybucket", collection="mycollection") |
47 | 50 | return client
|
48 | 51 |
|
49 | 52 |
|
@@ -87,10 +90,11 @@ def endpoints_setup() -> Tuple[Endpoints, Dict]:
|
87 | 90 |
|
88 | 91 |
|
89 | 92 | @pytest.fixture
|
90 |
| -def batch_setup(mocker: MockerFixture) -> Client: |
91 |
| - client = mocker.MagicMock() |
| 93 | +def batch_setup(mocked_session, mocker: MockerFixture) -> Client: |
92 | 94 | mocker.sentinel.resp = {"responses": []}
|
93 |
| - client.session.request.return_value = (mocker.sentinel.resp, mocker.sentinel.headers) |
| 95 | + mocked_session.request.return_value = (mocker.sentinel.resp, mocker.sentinel.headers) |
| 96 | + client = mocker.MagicMock() |
| 97 | + client.session = mocked_session |
94 | 98 | return client
|
95 | 99 |
|
96 | 100 |
|
|
0 commit comments