Skip to content

Commit 1cfa594

Browse files
adding test
1 parent 386398a commit 1cfa594

File tree

1 file changed

+81
-3
lines changed

1 file changed

+81
-3
lines changed

services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces.py

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from collections.abc import AsyncIterator
2+
13
# pylint: disable=redefined-outer-name
24
# pylint: disable=unused-argument
35
# pylint: disable=unused-variable
@@ -46,6 +48,7 @@ async def test_workspaces_user_role_permissions(
4648
logged_user: UserInfoDict,
4749
user_project: ProjectDict,
4850
expected: ExpectedResponse,
51+
workspaces_clean_db: AsyncIterator[None],
4952
):
5053
assert client.app
5154

@@ -60,6 +63,7 @@ async def test_workspaces_workflow(
6063
logged_user: UserInfoDict,
6164
user_project: ProjectDict,
6265
expected: HTTPStatus,
66+
workspaces_clean_db: AsyncIterator[None],
6367
):
6468
assert client.app
6569

@@ -139,13 +143,87 @@ async def test_workspaces_workflow(
139143

140144

141145
@pytest.mark.parametrize("user_role,expected", [(UserRole.USER, status.HTTP_200_OK)])
142-
async def test_project_workspace_movement_full_workflow(
146+
async def test_list_workspaces_with_text_search(
143147
client: TestClient,
144148
logged_user: UserInfoDict,
145149
user_project: ProjectDict,
146150
expected: HTTPStatus,
151+
workspaces_clean_db: AsyncIterator[None],
147152
):
148153
assert client.app
149154

150-
# NOTE: MD: not yet implemented
151-
# SEE https://github.com/ITISFoundation/osparc-simcore/issues/6778
155+
# list user workspaces
156+
url = client.app.router["list_workspaces"].url_for()
157+
resp = await client.get(f"{url}")
158+
data, _ = await assert_status(resp, status.HTTP_200_OK)
159+
assert data == []
160+
161+
# CREATE a new workspace
162+
url = client.app.router["create_workspace"].url_for()
163+
resp = await client.post(
164+
f"{url}",
165+
json={
166+
"name": "My first workspace",
167+
"description": "Custom description",
168+
"thumbnail": None,
169+
},
170+
)
171+
data, _ = await assert_status(resp, status.HTTP_201_CREATED)
172+
added_workspace = WorkspaceGet.model_validate(data)
173+
174+
# CREATE a new workspace
175+
url = client.app.router["create_workspace"].url_for()
176+
resp = await client.post(
177+
f"{url}",
178+
json={
179+
"name": "My second workspace",
180+
"description": "Sharing important projects",
181+
"thumbnail": None,
182+
},
183+
)
184+
data, _ = await assert_status(resp, status.HTTP_201_CREATED)
185+
added_workspace = WorkspaceGet.model_validate(data)
186+
187+
# LIST user workspaces
188+
url = client.app.router["list_workspaces"].url_for()
189+
resp = await client.get(f"{url}")
190+
data, _, meta, links = await assert_status(
191+
resp, status.HTTP_200_OK, include_meta=True, include_links=True
192+
)
193+
assert len(data) == 2
194+
195+
# LIST user workspaces
196+
url = (
197+
client.app.router["list_workspaces"]
198+
.url_for()
199+
.with_query({"filters": '{"text": "first"}'})
200+
)
201+
resp = await client.get(f"{url}")
202+
data, _, meta, links = await assert_status(
203+
resp, status.HTTP_200_OK, include_meta=True, include_links=True
204+
)
205+
assert len(data) == 1
206+
207+
# LIST user workspaces
208+
url = (
209+
client.app.router["list_workspaces"]
210+
.url_for()
211+
.with_query({"filters": '{"text": "important"}'})
212+
)
213+
resp = await client.get(f"{url}")
214+
data, _, meta, links = await assert_status(
215+
resp, status.HTTP_200_OK, include_meta=True, include_links=True
216+
)
217+
assert len(data) == 1
218+
219+
# LIST user workspaces
220+
url = (
221+
client.app.router["list_workspaces"]
222+
.url_for()
223+
.with_query({"filters": '{"text": "non-existing"}'})
224+
)
225+
resp = await client.get(f"{url}")
226+
data, _, meta, links = await assert_status(
227+
resp, status.HTTP_200_OK, include_meta=True, include_links=True
228+
)
229+
assert len(data) == 0

0 commit comments

Comments
 (0)