File tree Expand file tree Collapse file tree 5 files changed +33
-4
lines changed
Expand file tree Collapse file tree 5 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,13 @@ RUN python -m venv /venv
1313ENV 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
1717COPY . /context
1818WORKDIR /context
1919RUN 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
2323RUN apt-get update && apt-get install -y --no-install-recommends \
2424 curl \
2525 procps \
Original file line number Diff line number Diff line change 88 "roles": ["fake_person", "tester"],
99 "preferences": {
1010 "theme": "dark",
11- "notifications": 1
11+ "notifications": 1
Original file line number Diff line number Diff line change 1010 "theme" : " dark" ,
1111 "notifications" : true
1212 }
13- }
13+ }
Original file line number Diff line number Diff 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+
5870def 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 )
Original file line number Diff line number Diff 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" )
5471def test_get_file_contents_warns_and_gives_bytes_on_invalid_json (
5572 mock_request : MagicMock ,
You can’t perform that action at this time.
0 commit comments