Total Complexity | 5 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """Unit test fixtures.""" |
||
2 | # pylint: disable=redefined-outer-name |
||
3 | |||
4 | from unittest.mock import MagicMock |
||
5 | |||
6 | import pytest |
||
7 | |||
8 | from kytos.core import Controller |
||
9 | from kytos.core.auth import Auth |
||
10 | from kytos.lib.helpers import get_controller_mock |
||
11 | |||
12 | |||
13 | @pytest.fixture(autouse=True) |
||
14 | def ev_loop(monkeypatch, event_loop) -> None: |
||
15 | """asyncio event loop autouse fixture.""" |
||
16 | monkeypatch.setattr("asyncio.get_running_loop", lambda: event_loop) |
||
17 | yield event_loop |
||
18 | |||
19 | |||
20 | @pytest.fixture |
||
21 | def controller() -> Controller: |
||
22 | """Controller fixture.""" |
||
23 | Auth.get_user_controller = MagicMock() |
||
24 | yield get_controller_mock() |
||
25 | |||
26 | |||
27 | @pytest.fixture |
||
28 | def api_client(controller): |
||
29 | """Flask app test_client instance.""" |
||
30 | yield controller.api_server.app.test_client() |
||
31 | |||
32 | |||
33 | @pytest.fixture |
||
34 | def minimal_openapi_spec_dict(): |
||
35 | """Sample minimal openapi spec.""" |
||
36 | return { |
||
37 | "openapi": "3.0.0", |
||
38 | "info": {"title": "Minimal OpenAPI specification", "version": "0.1"}, |
||
39 | "paths": { |
||
40 | "/status": { |
||
41 | "get": { |
||
42 | "responses": {"default": {"description": "status"}} |
||
43 | } |
||
47 |