File: conftest.py

package info (click to toggle)
pyopenuv 2023.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 400 kB
  • sloc: python: 586; sh: 46; makefile: 3
file content (87 lines) | stat: -rw-r--r-- 2,526 bytes parent folder | download
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""Define dynamic text fixtures."""
from __future__ import annotations

import json
from typing import Any, cast

import pytest

from .common import load_fixture


@pytest.fixture(name="api_statistics_response", scope="session")
def api_statistics_response_fixture() -> dict[str, Any]:
    """Define a fixture to return an API status response.

    Returns:
        An API response payload.
    """
    return cast(
        dict[str, Any], json.loads(load_fixture("api_statistics_response.json"))
    )


@pytest.fixture(name="api_status_response", scope="session")
def api_status_response_fixture() -> dict[str, Any]:
    """Define a fixture to return an API status response.

    Returns:
        An API response payload.
    """
    return cast(dict[str, Any], json.loads(load_fixture("api_status_response.json")))


@pytest.fixture(name="error_invalid_api_key_response", scope="session")
def error_invalid_api_key_response_fixture() -> dict[str, Any]:
    """Define a fixture to return an invalid API key error response.

    Returns:
        An API response payload.
    """
    return cast(
        dict[str, Any], json.loads(load_fixture("error_invalid_api_key_response.json"))
    )


@pytest.fixture(name="error_rate_limit_response", scope="session")
def error_rate_limit_response_fixture() -> dict[str, Any]:
    """Define a fixture to return an rate limit error response.

    Returns:
        An API response payload.
    """
    return cast(
        dict[str, Any], json.loads(load_fixture("error_rate_limit_response.json"))
    )


@pytest.fixture(name="protection_window_response", scope="session")
def protection_window_response_fixture() -> dict[str, Any]:
    """Define a fixture to return a protection window response.

    Returns:
        An API response payload.
    """
    return cast(
        dict[str, Any], json.loads(load_fixture("protection_window_response.json"))
    )


@pytest.fixture(name="uv_forecast_response", scope="session")
def uv_forecast_response_fixture() -> dict[str, Any]:
    """Define a fixture to return an UV forecast response.

    Returns:
        An API response payload.
    """
    return cast(dict[str, Any], json.loads(load_fixture("uv_forecast_response.json")))


@pytest.fixture(name="uv_index_response", scope="session")
def uv_index_response_fixture() -> dict[str, Any]:
    """Define a fixture to return an UV index response.

    Returns:
        An API response payload.
    """
    return cast(dict[str, Any], json.loads(load_fixture("uv_index_response.json")))