소스 검색

workspace not found exception in workspace api + few tests for user endpoints

Guénaël Muller 6 년 전
부모
커밋
881a4a4683
2개의 변경된 파일1815개의 추가작업 그리고 163개의 파일을 삭제
  1. 10 2
      backend/tracim_backend/lib/core/workspace.py
  2. 1805 161
      backend/tracim_backend/tests/functional/test_user.py

+ 10 - 2
backend/tracim_backend/lib/core/workspace.py 파일 보기

@@ -3,9 +3,11 @@ import typing
3 3
 
4 4
 from sqlalchemy.orm import Query
5 5
 from sqlalchemy.orm import Session
6
+from sqlalchemy.orm.exc import NoResultFound
6 7
 
7 8
 from tracim_backend import CFG
8 9
 from tracim_backend.exceptions import EmptyLabelNotAllowed
10
+from tracim_backend.exceptions import WorkspaceNotFound
9 11
 from tracim_backend.lib.utils.translation import fake_translator as _
10 12
 
11 13
 from tracim_backend.lib.core.userworkspace import RoleApi
@@ -132,10 +134,16 @@ class WorkspaceApi(object):
132 134
         return workspace
133 135
 
134 136
     def get_one(self, id):
135
-        return self._base_query().filter(Workspace.workspace_id == id).one()
137
+        try:
138
+            return self._base_query().filter(Workspace.workspace_id == id).one()
139
+        except NoResultFound as exc:
140
+            raise WorkspaceNotFound('workspace {} does not exist or not visible for user'.format(id)) from exc  # nopep8
136 141
 
137 142
     def get_one_by_label(self, label: str) -> Workspace:
138
-        return self._base_query().filter(Workspace.label == label).one()
143
+        try:
144
+            return self._base_query().filter(Workspace.label == label).one()
145
+        except NoResultFound as exc:
146
+            raise WorkspaceNotFound('workspace {} does not exist or not visible for user'.format(id)) from exc  # nopep8
139 147
 
140 148
     """
141 149
     def get_one_for_current_user(self, id):

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1805 - 161
backend/tracim_backend/tests/functional/test_user.py