Passed
Push — master ( ad4b11...eeb2a1 )
by Vinicius
04:03 queued 15s
created

tests.conftest.ev_loop()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 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
                }
44
            }
45
        },
46
    }
47