test(settings): the adopt-zone test gives the account its zone — the session copy is refreshed from it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,13 +26,13 @@ def app():
|
|||||||
return create_app(testing=False)
|
return create_app(testing=False)
|
||||||
|
|
||||||
|
|
||||||
async def _client(app, role="admin"):
|
async def _client(app, role="admin", tz=None):
|
||||||
from steward.models.users import User, UserRole
|
from steward.models.users import User, UserRole
|
||||||
uid = str(uuid.uuid4())
|
uid = str(uuid.uuid4())
|
||||||
async with app.db_sessionmaker() as s:
|
async with app.db_sessionmaker() as s:
|
||||||
async with s.begin():
|
async with s.begin():
|
||||||
s.add(User(id=uid, username=f"adm-{uid[:8]}", email=f"{uid}@test",
|
s.add(User(id=uid, username=f"adm-{uid[:8]}", email=f"{uid}@test",
|
||||||
password_hash="x", role=UserRole(role), is_active=True))
|
password_hash="x", role=UserRole(role), is_active=True, time_zone=tz))
|
||||||
client = app.test_client()
|
client = app.test_client()
|
||||||
async with client.session_transaction() as sess:
|
async with client.session_transaction() as sess:
|
||||||
sess.update(user_id=uid, user_role=role, username=f"adm-{uid[:8]}",
|
sess.update(user_id=uid, user_role=role, username=f"adm-{uid[:8]}",
|
||||||
@@ -212,9 +212,7 @@ def test_the_first_admin_to_open_notifications_sets_the_also_send_to_zone(app):
|
|||||||
async with s.begin():
|
async with s.begin():
|
||||||
await set_setting(s, "smtp.tz", "")
|
await set_setting(s, "smtp.tz", "")
|
||||||
for zone in ("America/Chicago", "Asia/Tokyo"):
|
for zone in ("America/Chicago", "Asia/Tokyo"):
|
||||||
admin, _ = await _client(app)
|
admin, _ = await _client(app, tz=zone) # each request reads the zone from the account
|
||||||
async with admin.session_transaction() as sess:
|
|
||||||
sess["tz"] = zone
|
|
||||||
assert (await admin.get("/settings/notifications/")).status_code == 200
|
assert (await admin.get("/settings/notifications/")).status_code == 200
|
||||||
assert await _tz() == "America/Chicago" # the second admin's zone changes nothing
|
assert await _tz() == "America/Chicago" # the second admin's zone changes nothing
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user