From a03232a6a206a01f6888cd65c5c04b9455a39082 Mon Sep 17 00:00:00 2001 From: Wudext Date: Mon, 10 Apr 2023 16:10:06 +0300 Subject: [PATCH 1/3] Issue #33 --- migrations/versions/d35e88f39f85_fixing.py | 2 +- services_backend/routes/models/button.py | 4 ++-- tests/api/button.py | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/migrations/versions/d35e88f39f85_fixing.py b/migrations/versions/d35e88f39f85_fixing.py index f755c78..475aedd 100644 --- a/migrations/versions/d35e88f39f85_fixing.py +++ b/migrations/versions/d35e88f39f85_fixing.py @@ -30,7 +30,7 @@ def upgrade(): sa.text( f"""UPDATE "button" SET "order"={i + 1}, - "link"='{res_b[i][5]}', + "link"='{res_b[i][5].replace('~:text=%', '~:text=%')}', "type"='{res_b[i][6]}' WHERE id={res_b[i][0]}""" ) diff --git a/services_backend/routes/models/button.py b/services_backend/routes/models/button.py index 59cca46..1eca9de 100644 --- a/services_backend/routes/models/button.py +++ b/services_backend/routes/models/button.py @@ -17,7 +17,7 @@ class ButtonUpdate(Base): name: str | None = Field(description='Название кнопки') order: int | None = Field(description='Порядок, в котором отображаются кнопки') link: str | None = Field(description='Ссылка, на которую перенаправляет кнопка') - type: str | None = Field(description='Тип открываемой ссылки (Ссылка приложения/Браузер в приложении/Браузер') + type: Type | None = Field(description='Тип открываемой ссылки (Ссылка приложения/Браузер в приложении/Браузер') class ButtonGet(Base): @@ -26,4 +26,4 @@ class ButtonGet(Base): icon: str | None = Field(description='Иконка кнопки') name: str | None = Field(description='Название кнопки') link: str | None = Field(description='Ссылка, на которую перенаправляет кнопка') - type: str | None = Field(description='Тип открываемой ссылки (Ссылка приложения/Браузер в приложении/Браузер') + type: Type | None = Field(description='Тип открываемой ссылки (Ссылка приложения/Браузер в приложении/Браузер') diff --git a/tests/api/button.py b/tests/api/button.py index b841b23..c596e31 100644 --- a/tests/api/button.py +++ b/tests/api/button.py @@ -9,8 +9,8 @@ class TestButton: settings = get_settings() - def test_get_success(self, client, db_button, db_category): - res = client.get(f"/category/{db_category.id}/button/{db_button.id}") + async def test_get_success(self, client, db_button, db_category): + res = await client.get(f"/category/{db_category.id}/button/{db_button.id}") assert res.status_code == status.HTTP_200_OK assert res.json()['id'] == db_button.id @@ -153,3 +153,13 @@ def test_delete_order(self, db_button, client, db_category): res = client.get(f"/category/{db_category.id}/button/{db_button.id}") assert res.json()['order'] == 1 + + def test_type_not_enum(self, client, dbsession, db_category): + body = { + "icon": "test", + "name": "new", + "link": "test", + "type": "lmao", + } + res = client.post(f"/category/{db_category.id}/button/", data=json.dumps(body)) + assert res.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY From 7b8ef52e9137697488310168a3c7913b72e377d0 Mon Sep 17 00:00:00 2001 From: Wudext Date: Mon, 10 Apr 2023 16:14:25 +0300 Subject: [PATCH 2/3] Update d35e88f39f85_fixing.py --- migrations/versions/d35e88f39f85_fixing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/versions/d35e88f39f85_fixing.py b/migrations/versions/d35e88f39f85_fixing.py index 475aedd..f755c78 100644 --- a/migrations/versions/d35e88f39f85_fixing.py +++ b/migrations/versions/d35e88f39f85_fixing.py @@ -30,7 +30,7 @@ def upgrade(): sa.text( f"""UPDATE "button" SET "order"={i + 1}, - "link"='{res_b[i][5].replace('~:text=%', '~:text=%')}', + "link"='{res_b[i][5]}', "type"='{res_b[i][6]}' WHERE id={res_b[i][0]}""" ) From 7ab7dd4a8d91128de2424f941081cb82b219bd9e Mon Sep 17 00:00:00 2001 From: Wudext Date: Mon, 10 Apr 2023 16:14:51 +0300 Subject: [PATCH 3/3] Update button.py --- tests/api/button.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/api/button.py b/tests/api/button.py index c596e31..e2d667d 100644 --- a/tests/api/button.py +++ b/tests/api/button.py @@ -9,8 +9,8 @@ class TestButton: settings = get_settings() - async def test_get_success(self, client, db_button, db_category): - res = await client.get(f"/category/{db_category.id}/button/{db_button.id}") + def test_get_success(self, client, db_button, db_category): + res = client.get(f"/category/{db_category.id}/button/{db_button.id}") assert res.status_code == status.HTTP_200_OK assert res.json()['id'] == db_button.id