Skip to content

Commit 671cde3

Browse files
committed
improving tests
1 parent daa395d commit 671cde3

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

services/web/server/tests/unit/with_dbs/02/test_projects_states_handlers.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,7 @@ async def test_open_shared_project_multiple_users(
15291529
sio_i, sio_i_handlers = await create_socketio_connection_with_handlers(
15301530
client_i, client_i_tab_id
15311531
)
1532+
assert sio_i
15321533

15331534
# user i opens the shared project
15341535
await _open_project(client_i, client_i_tab_id, shared_project, expected.ok)
@@ -1570,13 +1571,43 @@ async def test_open_shared_project_multiple_users(
15701571
user_n = await exit_stack.enter_async_context(
15711572
LoggedUser(client_n, {"role": logged_user["role"]})
15721573
)
1574+
assert user_n
15731575

15741576
sio_n, sio_n_handlers = await create_socketio_connection_with_handlers(
15751577
client_n, client_n_tab_id
15761578
)
1579+
assert sio_n
1580+
assert sio_n_handlers
15771581

1578-
# user i opens the shared project
1582+
# user i opens the shared project --> no events since it's blocked
15791583
await _open_project(client_n, client_n_tab_id, shared_project, expected.conflict)
1584+
await _assert_project_state_updated(
1585+
sio_n_handlers[SOCKET_IO_PROJECT_UPDATED_EVENT], shared_project, []
1586+
)
1587+
1588+
# close project from a random user shall trigger an event for all the other users
1589+
await _close_project(
1590+
base_client, base_client_tab_id, shared_project, expected.no_content
1591+
)
1592+
opened_project_state = opened_project_state.model_copy(
1593+
update={
1594+
"share_state": ProjectShareStateOutputSchema(
1595+
locked=False,
1596+
status=ProjectStatus.OPENED,
1597+
current_user_groupids=[
1598+
gid
1599+
for gid in opened_project_state.share_state.current_user_groupids
1600+
if gid
1601+
!= TypeAdapter(GroupID).validate_python(logged_user["primary_gid"])
1602+
],
1603+
),
1604+
}
1605+
)
1606+
await _assert_project_state_updated(
1607+
sio_base_handlers[SOCKET_IO_PROJECT_UPDATED_EVENT],
1608+
shared_project,
1609+
[opened_project_state] * 2,
1610+
)
15801611

15811612

15821613
@pytest.mark.parametrize(*standard_user_role_response())

0 commit comments

Comments
 (0)