Skip to content

Commit cc20f8d

Browse files
Make codecov happy
1 parent ce81e02 commit cc20f8d

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ RUN python -m venv /venv
1313
ENV PATH=/venv/bin:$PATH
1414

1515
# The build stage installs the context into the venv
16-
FROM developer as build
16+
FROM developer AS build
1717
COPY . /context
1818
WORKDIR /context
1919
RUN pip install .[server]
2020

2121
# The runtime stage copies the built venv into a slim runtime container
22-
FROM python:${PYTHON_VERSION}-slim as runtime
22+
FROM python:${PYTHON_VERSION}-slim AS runtime
2323
RUN apt-get update && apt-get install -y --no-install-recommends \
2424
curl \
2525
procps \

tests/test_data/test_bad_json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
"roles": ["fake_person", "tester"],
99
"preferences": {
1010
"theme": "dark",
11-
"notifications": 1
11+
"notifications": 1

tests/test_data/test_good_json.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
"theme": "dark",
1111
"notifications": true
1212
}
13-
}
13+
}

tests/unit_tests/test_api.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ async def test_get_configuration_on_plain_text_file(mock_app: TestClient):
5555
)
5656

5757

58+
async def test_get_configuration_raw_bytes(mock_app: TestClient):
59+
file_path = f"{TEST_DATA_DIR}/beamline_parameters.txt"
60+
with open(file_path, "rb") as f:
61+
expected_response = f.read()
62+
await _assert_get_and_response(
63+
mock_app,
64+
f"{ENDPOINTS.CONFIG}/{file_path}",
65+
expected_response,
66+
header={"Accept": ValidAcceptHeaders.RAW_BYTES},
67+
)
68+
69+
5870
def test_get_configuration_exception_on_invalid_file(mock_app: TestClient):
5971
file_path = f"{TEST_DATA_DIR}/nonexistent_file.yaml"
6072
response = mock_app.get(f"{ENDPOINTS.CONFIG}/{file_path}", headers=HEADER_DEFAULTS)

tests/unit_tests/test_client.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ def test_get_file_contents_default_header(mock_request: MagicMock):
5050
)
5151

5252

53+
@patch("daq_config_server.client.requests.get")
54+
def test_get_file_contents_with_bytes(mock_request: MagicMock):
55+
test_str = "test"
56+
mock_request.return_value = make_test_response(
57+
test_str, content_type=ValidAcceptHeaders.RAW_BYTES
58+
)
59+
file_path = test_str
60+
url = "url"
61+
server = ConfigServer(url)
62+
assert (
63+
server.get_file_contents(
64+
file_path, requested_response_format=RequestedResponseFormats.DICT
65+
)
66+
== test_str.encode()
67+
)
68+
69+
5370
@patch("daq_config_server.client.requests.get")
5471
def test_get_file_contents_warns_and_gives_bytes_on_invalid_json(
5572
mock_request: MagicMock,

0 commit comments

Comments
 (0)