-
Notifications
You must be signed in to change notification settings - Fork 421
/
Copy pathconftest.py
96 lines (66 loc) · 2.35 KB
/
conftest.py
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
88
89
90
91
92
93
94
95
96
from typing import Any, Dict, List, Union
import pytest
from aws_lambda_powertools.metrics import (
MetricResolution,
Metrics,
MetricUnit,
)
from aws_lambda_powertools.metrics.base import reset_cold_start_flag
@pytest.fixture(scope="function", autouse=True)
def reset_metric_set():
metrics = Metrics()
metrics.clear_metrics()
metrics.clear_default_dimensions()
reset_cold_start_flag() # ensure each test has cold start
yield
@pytest.fixture
def metric_with_resolution() -> Dict[str, Union[str, int]]:
return {"name": "single_metric", "unit": MetricUnit.Count, "value": 1, "resolution": MetricResolution.High}
@pytest.fixture
def metric() -> Dict[str, str]:
return {"name": "single_metric", "unit": MetricUnit.Count, "value": 1}
@pytest.fixture
def metric_datadog() -> Dict[str, str]:
return {"name": "single_metric", "value": 1, "timestamp": 1691678198, "powertools": "datadog"}
@pytest.fixture
def metrics() -> List[Dict[str, str]]:
return [
{"name": "metric_one", "unit": MetricUnit.Count, "value": 1},
{"name": "metric_two", "unit": MetricUnit.Count, "value": 1},
]
@pytest.fixture
def metrics_same_name() -> List[Dict[str, str]]:
return [
{"name": "metric_one", "unit": MetricUnit.Count, "value": 1},
{"name": "metric_one", "unit": MetricUnit.Count, "value": 5},
]
@pytest.fixture
def dimension() -> Dict[str, str]:
return {"name": "test_dimension", "value": "test"}
@pytest.fixture
def dimensions() -> List[Dict[str, str]]:
return [
{"name": "test_dimension", "value": "test"},
{"name": "test_dimension_2", "value": "test"},
]
@pytest.fixture
def non_str_dimensions() -> List[Dict[str, Any]]:
return [
{"name": "test_dimension", "value": True},
{"name": "test_dimension_2", "value": 3},
]
@pytest.fixture
def namespace() -> str:
return "test_namespace"
@pytest.fixture
def service() -> str:
return "test_service"
@pytest.fixture
def metadata() -> Dict[str, str]:
return {"key": "username", "value": "test"}
@pytest.fixture
def a_hundred_metrics() -> List[Dict[str, str]]:
return [{"name": f"metric_{i}", "unit": "Count", "value": 1} for i in range(100)]
@pytest.fixture
def a_hundred_metric_values() -> List[Dict[str, str]]:
return [{"name": "metric", "unit": "Count", "value": i} for i in range(100)]