forked from mongodb/mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcedar_report.py
44 lines (35 loc) · 1.01 KB
/
cedar_report.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
"""Cedar report."""
from dataclasses import dataclass
from typing import List, Union
@dataclass
class CedarMetric:
"""Structure that holds metrics for Cedar."""
name: str
type: str
value: Union[int, float]
user_submitted: bool = False
def as_dict(self) -> dict:
"""Return dictionary representation."""
return {
"name": self.name,
"type": self.type,
"value": self.value,
"user_submitted": self.user_submitted,
}
@dataclass
class CedarTestReport:
"""Structure that holds test report for Cedar."""
test_name: str
thread_level: int
metrics: List[CedarMetric]
def as_dict(self) -> dict:
"""Return dictionary representation."""
return {
"info": {
"test_name": self.test_name,
"args": {
"thread_level": self.thread_level,
},
},
"metrics": [metric.as_dict() for metric in self.metrics],
}