|
| 1 | +# pylint: disable=protected-access |
1 | 2 | # pylint: disable=redefined-outer-name |
2 | 3 |
|
3 | 4 | from collections.abc import Awaitable, Callable |
@@ -25,35 +26,50 @@ async def fake_project( |
25 | 26 | create_fake_project: Callable[..., Awaitable[RowProxy]], |
26 | 27 | create_fake_nodes: Callable[..., Awaitable[RowProxy]], |
27 | 28 | ) -> RowProxy: |
28 | | - project: RowProxy = await create_fake_project(connection, fake_user, hidden=True) |
| 29 | + project: RowProxy = await create_fake_project(connection, fake_user) |
29 | 30 | await create_fake_nodes(project) |
30 | 31 | return project |
31 | 32 |
|
32 | 33 |
|
| 34 | +async def _assert_allows_to_psuh( |
| 35 | + asyncpg_engine: AsyncEngine, project_uuid: str, *, expected: bool |
| 36 | +) -> None: |
| 37 | + result = await ProjectsExtensionsRepo.allows_guests_to_push_states_and_output_ports( |
| 38 | + asyncpg_engine, project_uuid=project_uuid |
| 39 | + ) |
| 40 | + assert result is expected |
| 41 | + |
| 42 | + |
33 | 43 | async def test_workflow( |
34 | 44 | asyncpg_engine: AsyncEngine, |
35 | 45 | connection: SAConnection, |
36 | 46 | create_fake_user: Callable[..., Awaitable[RowProxy]], |
37 | 47 | create_fake_project: Callable[..., Awaitable[RowProxy]], |
38 | 48 | ): |
39 | 49 | user: RowProxy = await create_fake_user(connection) |
40 | | - project: RowProxy = await create_fake_project(connection, user, hidden=True) |
| 50 | + project: RowProxy = await create_fake_project(connection, user) |
41 | 51 |
|
42 | | - assert ( |
43 | | - await ProjectsExtensionsRepo.allows_guests_to_push_states_and_output_ports( |
44 | | - asyncpg_engine, project_uuid=project["uuid"] |
45 | | - ) |
46 | | - is False |
47 | | - ) |
| 52 | + await _assert_allows_to_psuh(asyncpg_engine, project["uuid"], expected=False) |
48 | 53 |
|
49 | 54 | # add the entry in the table |
50 | | - await ProjectsExtensionsRepo.set_allow_guests_to_push_states_and_output_ports( |
| 55 | + await ProjectsExtensionsRepo._set_allow_guests_to_push_states_and_output_ports( |
51 | 56 | asyncpg_engine, project_uuid=project["uuid"] |
52 | 57 | ) |
53 | 58 |
|
| 59 | + await _assert_allows_to_psuh(asyncpg_engine, project["uuid"], expected=True) |
| 60 | + |
| 61 | + copy_project: RowProxy = await create_fake_project(connection, user) |
| 62 | + |
54 | 63 | assert ( |
55 | 64 | await ProjectsExtensionsRepo.allows_guests_to_push_states_and_output_ports( |
56 | | - asyncpg_engine, project_uuid=project["uuid"] |
| 65 | + asyncpg_engine, project_uuid=copy_project["uuid"] |
57 | 66 | ) |
58 | | - is True |
| 67 | + is False |
| 68 | + ) |
| 69 | + await _assert_allows_to_psuh(asyncpg_engine, copy_project["uuid"], expected=False) |
| 70 | + await ProjectsExtensionsRepo.copy_allow_guests_to_push_states_and_output_ports( |
| 71 | + asyncpg_engine, |
| 72 | + from_project_uuid=project["uuid"], |
| 73 | + to_project_uuid=copy_project["uuid"], |
59 | 74 | ) |
| 75 | + await _assert_allows_to_psuh(asyncpg_engine, copy_project["uuid"], expected=True) |
0 commit comments