Skip to content

Commit 4877f65

Browse files
chore: fix and add tests
1 parent 7f4cd7a commit 4877f65

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/test_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ def setUp(self):
2222
)
2323
self.env_patcher.start()
2424

25+
def tearDown(self):
26+
self.env_patcher.stop()
27+
2528
@patch("botocore.session.Session.create_client")
2629
def test_secrets_manager_fips_endpoint(self, mock_boto3_client):
2730
mock_client = MagicMock()

tests/test_metric.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ def test_lambda_metric_timestamp_with_extension(self):
5858
"test_timestamp", 1, timestamp=timestamp, tags=[dd_lambda_layer_tag]
5959
)
6060

61+
@patch("os.environ", {"AWS_REGION": "us-gov-west-1"})
62+
@patch("datadog_lambda.metric.should_use_extension", True)
63+
def test_lambda_metric_timestamp_with_extension_in_govcloud(self):
64+
patcher = patch("datadog_lambda.metric.extension_thread_stats")
65+
self.mock_metric_extension_thread_stats = patcher.start()
66+
self.addCleanup(patcher.stop)
67+
68+
delta = timedelta(minutes=1)
69+
timestamp = int((datetime.now() - delta).timestamp())
70+
71+
lambda_metric("test_timestamp", 1, timestamp)
72+
self.mock_metric_lambda_stats.distribution.assert_not_called()
73+
self.mock_metric_extension_thread_stats.distribution.assert_not_called()
74+
6175
@patch("datadog_lambda.metric.should_use_extension", True)
6276
def test_lambda_metric_datetime_with_extension(self):
6377
patcher = patch("datadog_lambda.metric.extension_thread_stats")

0 commit comments

Comments
 (0)