Total Complexity | 5 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | """Unit test fixtures.""" |
||
2 | # pylint: disable=redefined-outer-name |
||
3 | |||
4 | 1 | import pytest |
|
5 | 1 | from httpx import AsyncClient |
|
6 | |||
7 | 1 | from kytos.core import Controller |
|
8 | 1 | from kytos.core.auth import Auth |
|
9 | 1 | from kytos.core.dead_letter import DeadLetter |
|
10 | 1 | from kytos.lib.helpers import get_controller_mock |
|
11 | |||
12 | |||
13 | 1 | @pytest.fixture |
|
14 | 1 | def controller() -> Controller: |
|
15 | """Controller fixture.""" |
||
16 | 1 | yield get_controller_mock() |
|
17 | |||
18 | |||
19 | 1 | @pytest.fixture |
|
20 | 1 | def dead_letter(controller) -> DeadLetter: |
|
21 | """DeadLetter fixture.""" |
||
22 | 1 | yield controller.dead_letter |
|
23 | |||
24 | |||
25 | 1 | @pytest.fixture |
|
26 | 1 | def api_client(controller) -> AsyncClient: |
|
27 | """App test_client instance.""" |
||
28 | 1 | base_url = "http://127.0.0.1/api/" |
|
29 | 1 | app = controller.api_server.app |
|
30 | 1 | yield AsyncClient(app=app, base_url=base_url) |
|
31 | |||
32 | |||
33 | 1 | @pytest.fixture |
|
34 | 1 | def auth(controller) -> Auth: |
|
35 | """Auth fixture.""" |
||
36 | 1 | auth = Auth(controller) |
|
37 | 1 | controller.start_auth() |
|
38 | 1 | yield auth |
|
39 | |||
40 | |||
41 | 1 | @pytest.fixture |
|
42 | 1 | def minimal_openapi_spec_dict(): |
|
43 | """Sample minimal openapi spec.""" |
||
44 | 1 | return { |
|
45 | "openapi": "3.0.0", |
||
46 | "info": {"title": "Minimal OpenAPI specification", "version": "0.1"}, |
||
47 | "paths": { |
||
48 | "/status": { |
||
49 | "get": { |
||
50 | "responses": {"default": {"description": "status"}} |
||
51 | } |
||
55 |