@@ -271,19 +271,19 @@ def test_get_user__skip_cache(caplog, ppms_connection, ppms_user):
271
271
assert os .path .exists (cached ) is False
272
272
273
273
ppms_connection .get_user (ppms_user .username )
274
- assert "Doing an on-line request: No cache hit for" in caplog . text
274
+ assert ppms_connection . last_served_from_cache is False
275
275
assert "Read intercepted response text from" not in caplog .text
276
276
277
277
assert os .path .exists (cached ) is True
278
278
279
279
caplog .clear ()
280
280
ppms_connection .get_user (ppms_user .username )
281
- assert "Doing an on-line request: No cache hit for" not in caplog . text
281
+ assert ppms_connection . last_served_from_cache is True
282
282
assert "Read intercepted response text from" in caplog .text
283
283
284
284
caplog .clear ()
285
285
ppms_connection .get_user (ppms_user .username , skip_cache = True )
286
- assert "Doing an on-line request: Skipping the cache" in caplog . text
286
+ assert ppms_connection . last_served_from_cache is False
287
287
assert "Read intercepted response text from" not in caplog .text
288
288
289
289
# make sure to clean up the test-specific cache again:
@@ -409,12 +409,10 @@ def test_update_systems(ppms_connection, caplog):
409
409
"""Test the get_systems() method."""
410
410
caplog .set_level (logging .DEBUG )
411
411
switch_cache_mocks (ppms_connection , "update_systems__broken_id" )
412
- systems = ppms_connection .get_systems ()
413
-
412
+ assert len ( ppms_connection .systems ) == 0
413
+ ppms_connection . get_systems ()
414
414
# results should contain exaclty one system:
415
- assert len (systems ) == 1
416
- assert "Updated 1 bookable systems from PPMS" in caplog .text
417
- assert "1 systems failed parsing" in caplog .text
415
+ assert len (ppms_connection .systems ) == 1
418
416
419
417
420
418
def test_get_systems_matching (ppms_connection , system_details_raw ):
@@ -819,9 +817,11 @@ def test_flush_cache__keep_users__request_new(ppms_connection, caplog, tmp_path)
819
817
820
818
log .info (f"Requesting details from PUMAPI for cached user [{ old_user_name } ]" )
821
819
ppms_connection .get_user (old_user_name )
822
- assert "No cache hit" not in caplog .text # served from the cache
820
+ assert ppms_connection .last_served_from_cache is True
821
+ # assert "No cache hit" not in caplog.text # served from the cache
823
822
824
823
log .info (f"Requesting details from PUMAPI for 'new' user [{ new_user_name } ]" )
825
824
ppms_connection .get_user (new_user_name )
826
- assert "No cache hit" in caplog .text # requires an on-line request
825
+ assert ppms_connection .last_served_from_cache is False
826
+ # assert "No cache hit" in caplog.text # requires an on-line request
827
827
assert os .path .exists (new_user_cache )
0 commit comments