File: test_get_total_output.py

package info (click to toggle)
python-apsystems-ez1 2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,328 kB
  • sloc: python: 697; makefile: 5
file content (80 lines) | stat: -rw-r--r-- 1,967 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
import pytest


@pytest.mark.asyncio
@pytest.mark.parametrize(
    "output_data, expected_total_energy, test_id",
    [
        # Happy path tests with various realistic test values
        (
            {
                "data": {
                    "p1": 5000.0,
                    "p2": 3000.0,
                    "te1": 0.0,
                    "te2": 0.0,
                    "e1": 0.0,
                    "e2": 0.0,
                }, "status": 0
            },
            8000.0,
            "happy_path_1",
        ),
        (
            {
                "data": {
                    "p1": 1234.56,
                    "p2": 789.01,
                    "te1": 0.0,
                    "te2": 0.0,
                    "e1": 0.0,
                    "e2": 0.0,
                }, "status": 0
            },
            2023.57,
            "happy_path_2",
        ),
        # Edge cases
        (
            {
                "data": {
                    "p1": 0.0,
                    "p2": 3000.0,
                    "te1": 0.0,
                    "te2": 0.0,
                    "e1": 0.0,
                    "e2": 0.0,
                }, "status": 0
            },
            3000.0,
            "edge_case_1",
        ),
        (
            {
                "data": {
                    "p1": 3000.0,
                    "p2": 0.0,
                    "te1": 0.0,
                    "te2": 0.0,
                    "e1": 0.0,
                    "e2": 0.0,
                }, "status": 0
            },
            3000.0,
            "edge_case_2",
        ),
        ## Error cases
        (None, None, "error_case_1"),
    ],
)
async def test_get_total_output(
    output_data, expected_total_energy, test_id, mock_response
):
    # Arrange
    ez1m = mock_response(output_data)

    # Act
    total_energy = await ez1m.get_total_output()

    # Assert
    assert total_energy == expected_total_energy, f"Test failed for {test_id}"