@@ -148,11 +148,12 @@ def test_catch_all_route(ui_app_with_registry):
148148# ---------- projects-list.json tests ----------
149149
150150
151- def _read_projects_list (temp_dir ):
152- """Read the projects-list.json written by get_app via the mock (ui_dir = temp_dir)."""
153- projects_file = os .path .join (temp_dir , "projects-list.json" )
154- with open (projects_file ) as f :
155- return json .load (f )
151+ def _get_projects_list (app ):
152+ """Fetch the dynamic projects-list.json endpoint."""
153+ client = TestClient (app )
154+ resp = client .get ("/projects-list.json" )
155+ assertpy .assert_that (resp .status_code ).is_equal_to (EXPECTED_SUCCESS_STATUS )
156+ return resp .json ()
156157
157158
158159def test_projects_list_registry_path (mock_feature_store ):
@@ -165,9 +166,9 @@ def test_projects_list_registry_path(mock_feature_store):
165166 _create_mock_ui_files (temp_dir )
166167
167168 with _setup_importlib_mocks (temp_dir ):
168- get_app (mock_feature_store , TEST_PROJECT_NAME )
169+ app = get_app (mock_feature_store , TEST_PROJECT_NAME )
169170
170- data = _read_projects_list ( temp_dir )
171+ data = _get_projects_list ( app )
171172 assertpy .assert_that (data ["projects" ][0 ]["registryPath" ]).is_equal_to ("/api/v1" )
172173
173174
@@ -181,13 +182,13 @@ def test_projects_list_with_root_path(mock_feature_store):
181182 _create_mock_ui_files (temp_dir )
182183
183184 with _setup_importlib_mocks (temp_dir ):
184- get_app (
185+ app = get_app (
185186 mock_feature_store ,
186187 TEST_PROJECT_NAME ,
187188 root_path = "/feast" ,
188189 )
189190
190- data = _read_projects_list ( temp_dir )
191+ data = _get_projects_list ( app )
191192 assertpy .assert_that (data ["projects" ][0 ]["registryPath" ]).is_equal_to (
192193 "/feast/api/v1"
193194 )
@@ -206,9 +207,9 @@ def test_projects_list_multiple_projects(mock_feature_store):
206207 _create_mock_ui_files (temp_dir )
207208
208209 with _setup_importlib_mocks (temp_dir ):
209- get_app (mock_feature_store , TEST_PROJECT_NAME )
210+ app = get_app (mock_feature_store , TEST_PROJECT_NAME )
210211
211- data = _read_projects_list ( temp_dir )
212+ data = _get_projects_list ( app )
212213 assertpy .assert_that (len (data ["projects" ])).is_equal_to (3 )
213214 assertpy .assert_that (data ["projects" ][0 ]["id" ]).is_equal_to ("all" )
214215 assertpy .assert_that (data ["projects" ][1 ]["id" ]).is_equal_to ("project_alpha" )
@@ -225,9 +226,9 @@ def test_projects_list_fallback_on_empty(mock_feature_store):
225226 _create_mock_ui_files (temp_dir )
226227
227228 with _setup_importlib_mocks (temp_dir ):
228- get_app (mock_feature_store , TEST_PROJECT_NAME )
229+ app = get_app (mock_feature_store , TEST_PROJECT_NAME )
229230
230- data = _read_projects_list ( temp_dir )
231+ data = _get_projects_list ( app )
231232 assertpy .assert_that (len (data ["projects" ])).is_equal_to (1 )
232233 assertpy .assert_that (data ["projects" ][0 ]["id" ]).is_equal_to (TEST_PROJECT_NAME )
233234
@@ -242,8 +243,40 @@ def test_projects_list_fallback_on_exception(mock_feature_store):
242243 _create_mock_ui_files (temp_dir )
243244
244245 with _setup_importlib_mocks (temp_dir ):
245- get_app (mock_feature_store , TEST_PROJECT_NAME )
246+ app = get_app (mock_feature_store , TEST_PROJECT_NAME )
246247
247- data = _read_projects_list ( temp_dir )
248+ data = _get_projects_list ( app )
248249 assertpy .assert_that (len (data ["projects" ])).is_equal_to (1 )
249250 assertpy .assert_that (data ["projects" ][0 ]["id" ]).is_equal_to (TEST_PROJECT_NAME )
251+
252+
253+ def test_projects_list_dynamic_refresh (mock_feature_store ):
254+ """New projects appear without restarting the server."""
255+ mock_registry = MagicMock ()
256+ mock_registry .list_projects .return_value = [
257+ _make_project_mock ("picked_elk" ),
258+ ]
259+ mock_feature_store .registry = mock_registry
260+
261+ with tempfile .TemporaryDirectory () as temp_dir :
262+ _create_mock_ui_files (temp_dir )
263+
264+ with _setup_importlib_mocks (temp_dir ):
265+ app = get_app (mock_feature_store , TEST_PROJECT_NAME )
266+
267+ client = TestClient (app )
268+
269+ data = client .get ("/projects-list.json" ).json ()
270+ assertpy .assert_that (len (data ["projects" ])).is_equal_to (1 )
271+ assertpy .assert_that (data ["projects" ][0 ]["id" ]).is_equal_to ("picked_elk" )
272+
273+ mock_registry .list_projects .return_value = [
274+ _make_project_mock ("picked_elk" ),
275+ _make_project_mock ("picked_elk2" ),
276+ ]
277+
278+ data = client .get ("/projects-list.json" ).json ()
279+ assertpy .assert_that (len (data ["projects" ])).is_equal_to (3 )
280+ assertpy .assert_that (data ["projects" ][0 ]["id" ]).is_equal_to ("all" )
281+ assertpy .assert_that (data ["projects" ][1 ]["id" ]).is_equal_to ("picked_elk" )
282+ assertpy .assert_that (data ["projects" ][2 ]["id" ]).is_equal_to ("picked_elk2" )
0 commit comments