Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dperl-dls committed Jun 24, 2024
1 parent 437ae99 commit 15c6e01
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ server = ["fastapi", "redis", "hiredis"]
dev = [
"copier",
"httpx",
"mockito",
"pipdeptree",
"pre-commit",
"pyright",
Expand Down
1 change: 1 addition & 0 deletions src/daq_config_server/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@dataclass(frozen=True)
class Endpoints:
FEATURE = "/featureflag"
FEATURE_DISALLOWED_SPECIALS = ["all"]
BL_PARAM = "/beamlineparameters"
INFO = "/info"

Expand Down
13 changes: 13 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
from fastapi import status
from fastapi.testclient import TestClient
from mockito import when

from daq_config_server.app import app
from daq_config_server.beamline_parameters import GDABeamlineParameters
Expand Down Expand Up @@ -52,3 +53,15 @@ async def test_get_feature_list(self, mock_valkey: MagicMock, mock_app):
ENDPOINTS.FEATURE,
test_param_list,
)

@patch("daq_config_server.app.valkey")
async def test_get_feature_list_w_values(self, mock_valkey: MagicMock, mock_app):
test_params = {"param_1": True, "param_2": True, "param_3": False}
mock_valkey.smembers.return_value = list(test_params.keys())
for param, value in test_params.items():
when(mock_valkey).get(param).thenReturn(value)
await _assert_get_and_response(
mock_app,
ENDPOINTS.FEATURE + "?get_values=true",
test_params,
)

0 comments on commit 15c6e01

Please sign in to comment.