13
13
14
14
class TestMetrics (unittest .TestCase ):
15
15
def test_upload_gauge_metric (self ):
16
+ """Test that we can upload a gauge metric correctly.
17
+
18
+ Also verify that we pass around parameters like API keys and user IDs
19
+ correctly to the HTTP POST request.
20
+ """
16
21
test_metrics = [metrics .GaugeMetric ("gauge_test" , 5 , 1000 )]
17
22
return_value = requests .Response ()
18
23
return_value .status_code = 204
@@ -29,6 +34,7 @@ def test_upload_gauge_metric(self):
29
34
)
30
35
31
36
def test_upload_job_metric (self ):
37
+ """Test that we can upload a job metric correctly."""
32
38
test_metrics = [
33
39
metrics .JobMetrics ("test_job" , 5 , 10 , 1 , 1000 , 7 , "test_workflow" )
34
40
]
@@ -44,6 +50,8 @@ def test_upload_job_metric(self):
44
50
)
45
51
46
52
def test_upload_unknown_metric (self ):
53
+ """Test we report an error if we encounter an unknown metric type."""
54
+
47
55
@dataclass
48
56
class FakeMetric :
49
57
fake_data : str
@@ -54,6 +62,7 @@ class FakeMetric:
54
62
metrics .upload_metrics (test_metrics , "test_userid" , "test_api_key" )
55
63
56
64
def test_bad_response_code (self ):
65
+ """Test that we gracefully handle HTTP response errors."""
57
66
test_metrics = [metrics .GaugeMetric ("gauge_test" , 5 , 1000 )]
58
67
return_value = requests .Response ()
59
68
return_value .status_code = 403
0 commit comments