Passed
Pull Request — master (#375)
by Vinicius
08:19
created

tests.conftest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 51
rs 10
c 0
b 0
f 0
ccs 25
cts 25
cp 1
wmc 5

5 Functions

Rating   Name   Duplication   Size   Complexity  
A controller() 0 4 1
A api_client() 0 6 1
A auth() 0 6 1
A dead_letter() 0 4 1
A minimal_openapi_spec_dict() 0 10 1
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
                }
52
            }
53
        },
54
    }
55