Skip to content

Commit dc7957c

Browse files
authored
fix flaky tests due to header casing (#2483)
1 parent fd6205c commit dc7957c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

tests/test_async.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import time
33

44
import pytest
5+
from aiosonic import HttpHeaders
56

67
from datadog_api_client.api_client import AsyncApiClient
78
from datadog_api_client.configuration import Configuration
@@ -21,7 +22,9 @@ async def test_error():
2122
error = str(e.value)
2223
assert "(403)" in error
2324
assert "Reason: Forbidden" in error
24-
assert e.value.headers["Content-Type"] == "application/json"
25+
# cast headers to HttpHeaders to make them case insensitive
26+
headers = HttpHeaders(e.value.headers)
27+
assert headers["content-type"] == "application/json"
2528
assert e.value.body["errors"] == ["Forbidden"]
2629

2730

@@ -41,7 +44,8 @@ async def test_basic():
4144
api_instance = dashboards_api.DashboardsApi(api_client)
4245
_, code, headers = await api_instance.list_dashboards()
4346
assert code == 200
44-
assert headers["Content-Type"] == "application/json"
47+
headers = HttpHeaders(headers)
48+
assert headers["content-type"] == "application/json"
4549

4650

4751
@pytest.mark.asyncio

tests/test_thread.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22

33
import pytest
4+
from aiosonic import HttpHeaders
45

56
from datadog_api_client.api_client import ThreadedApiClient
67
from datadog_api_client.configuration import Configuration
@@ -23,4 +24,6 @@ def test_basic():
2324
thread = api_instance.list_dashboards()
2425
_, code, headers = thread.get()
2526
assert code == 200
26-
assert headers["Content-Type"] == "application/json"
27+
# cast headers to HttpHeaders to make them case insensitive
28+
headers = HttpHeaders(headers)
29+
assert headers["content-type"] == "application/json"

0 commit comments

Comments
 (0)