File: conftest.py

package info (click to toggle)
python-nice-go 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 608 kB
  • sloc: python: 1,981; makefile: 3
file content (56 lines) | stat: -rw-r--r-- 1,417 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Fixtures for tests."""

# ruff: noqa: SLF001

from unittest.mock import AsyncMock, MagicMock

import pytest
from tenacity import wait_none

from nice_go._aws_cognito_authenticator import AwsCognitoAuthenticator
from nice_go._ws_client import WebSocketClient
from nice_go.nice_go_api import NiceGOApi


@pytest.fixture
def mock_api() -> NiceGOApi:
    """Mocked NiceGOApi instance."""
    api = NiceGOApi()
    api._session = AsyncMock()
    api._device_ws = AsyncMock()
    api._endpoints = {
        "GraphQL": {
            "device": {
                "wss": "wss://test",
                "https": "https://test",
            },
            "events": {
                "wss": "wss://test",
                "https": "https://test",
            },
        },
    }
    api.connect.retry.wait = wait_none()  # type: ignore[attr-defined]
    return api


@pytest.fixture
def mock_ws_client() -> WebSocketClient:
    """Mocked WebSocketClient instance."""
    ws = WebSocketClient(client_session=MagicMock())
    ws.ws = AsyncMock(closed=False)
    ws._dispatch = MagicMock()
    ws.id_token = "test_token"
    ws.host = "test_host"
    return ws


@pytest.fixture
def mock_authenticator() -> AwsCognitoAuthenticator:
    """Mocked AwsCognitoAuthenticator instance."""
    return AwsCognitoAuthenticator(
        "test_region",
        "test_client_id",
        "test_pool_id",
        "test_identity_pool_id",
    )