Update.
This commit is contained in:
parent
e228a2e59c
commit
81f1cfd200
@ -23,17 +23,18 @@ def temp_user_files_dir(tmp_path):
|
|||||||
def temp_users_json(tmp_path):
|
def temp_users_json(tmp_path):
|
||||||
"""Fixture to create a temporary users.json file."""
|
"""Fixture to create a temporary users.json file."""
|
||||||
users_json_path = tmp_path / "users.json"
|
users_json_path = tmp_path / "users.json"
|
||||||
initial_users_data = {
|
initial_users_data = [
|
||||||
"test@example.com": {
|
{
|
||||||
"full_name": "Test User",
|
|
||||||
"email": "test@example.com",
|
"email": "test@example.com",
|
||||||
|
"full_name": "Test User",
|
||||||
"password": "hashed_password",
|
"password": "hashed_password",
|
||||||
"storage_quota_gb": 10,
|
"storage_quota_gb": 10,
|
||||||
"storage_used_gb": 0,
|
"storage_used_gb": 0,
|
||||||
"parent_email": None,
|
"parent_email": None,
|
||||||
"shared_items": {}
|
"shared_items": {}
|
||||||
},
|
},
|
||||||
"child@example.com": {
|
{
|
||||||
|
"email": "child@example.com",
|
||||||
"full_name": "Child User",
|
"full_name": "Child User",
|
||||||
"email": "child@example.com",
|
"email": "child@example.com",
|
||||||
"password": "hashed_password",
|
"password": "hashed_password",
|
||||||
@ -42,7 +43,7 @@ def temp_users_json(tmp_path):
|
|||||||
"parent_email": "test@example.com",
|
"parent_email": "test@example.com",
|
||||||
"shared_items": {}
|
"shared_items": {}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
with open(users_json_path, "w") as f:
|
with open(users_json_path, "w") as f:
|
||||||
json.dump(initial_users_data, f)
|
json.dump(initial_users_data, f)
|
||||||
return users_json_path
|
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")
|
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)
|
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)
|
future_time = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=8)
|
||||||
mocker.patch("datetime.datetime", MagicMock(wraps=datetime.datetime))
|
mock_datetime = mocker.patch('retoors.services.file_service.datetime', wraps=datetime)
|
||||||
datetime.datetime.now.return_value = future_time
|
mock_datetime.datetime.now = mocker.Mock(return_value=future_time)
|
||||||
|
|
||||||
shared_item = await file_service_instance.get_shared_item(share_id)
|
shared_item = await file_service_instance.get_shared_item(share_id)
|
||||||
assert shared_item is None
|
assert shared_item is None
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user