diff --git a/tests/test_file_browser.py b/tests/test_file_browser.py index 91f7ea5..7383b24 100644 --- a/tests/test_file_browser.py +++ b/tests/test_file_browser.py @@ -23,17 +23,18 @@ def temp_user_files_dir(tmp_path): def temp_users_json(tmp_path): """Fixture to create a temporary users.json file.""" users_json_path = tmp_path / "users.json" - initial_users_data = { - "test@example.com": { - "full_name": "Test User", + initial_users_data = [ + { "email": "test@example.com", + "full_name": "Test User", "password": "hashed_password", "storage_quota_gb": 10, "storage_used_gb": 0, "parent_email": None, "shared_items": {} }, - "child@example.com": { + { + "email": "child@example.com", "full_name": "Child User", "email": "child@example.com", "password": "hashed_password", @@ -42,7 +43,7 @@ def temp_users_json(tmp_path): "parent_email": "test@example.com", "shared_items": {} } - } + ] with open(users_json_path, "w") as f: json.dump(initial_users_data, f) return users_json_path @@ -310,10 +311,10 @@ async def test_file_service_shared_link_expiry(file_service_instance, mocker): await file_service_instance.upload_file(user_email, file_path, b"expiring content") share_id = await file_service_instance.generate_share_link(user_email, file_path) - # Mock datetime to simulate an expired link + # Mock datetime to simulate an expired link (after generating the link) future_time = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=8) - mocker.patch("datetime.datetime", MagicMock(wraps=datetime.datetime)) - datetime.datetime.now.return_value = future_time + mock_datetime = mocker.patch('retoors.services.file_service.datetime', wraps=datetime) + mock_datetime.datetime.now = mocker.Mock(return_value=future_time) shared_item = await file_service_instance.get_shared_item(share_id) assert shared_item is None