@@ 2234-2287 (lines=54) @@ | ||
2231 | assert res.json_body[0]['content_id'] == firstly_created.content_id |
|
2232 | assert res.json_body[0]['read_by_user'] is False |
|
2233 | ||
2234 | def test_api_set_content_as_unread__ok__200__with_comments_read_comment_only(self): |
|
2235 | # init DB |
|
2236 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
2237 | admin = dbsession.query(models.User) \ |
|
2238 | .filter(models.User.email == '[email protected]') \ |
|
2239 | .one() |
|
2240 | workspace_api = WorkspaceApi( |
|
2241 | current_user=admin, |
|
2242 | session=dbsession, |
|
2243 | config=self.app_config |
|
2244 | ||
2245 | ) |
|
2246 | workspace = WorkspaceApi( |
|
2247 | current_user=admin, |
|
2248 | session=dbsession, |
|
2249 | config=self.app_config, |
|
2250 | ).create_workspace( |
|
2251 | 'test workspace', |
|
2252 | save_now=True |
|
2253 | ) |
|
2254 | api = ContentApi( |
|
2255 | current_user=admin, |
|
2256 | session=dbsession, |
|
2257 | config=self.app_config, |
|
2258 | ) |
|
2259 | main_folder = api.create(content_type_list.Folder.slug, workspace, None, 'this is randomized folder', '', True) # nopep8 |
|
2260 | # creation order test |
|
2261 | firstly_created = api.create(content_type_list.Page.slug, workspace, main_folder, 'creation_order_test', '', True) # nopep8 |
|
2262 | comments = api.create_comment(workspace, firstly_created, 'juste a super comment', True) # nopep8 |
|
2263 | api.mark_read(firstly_created) |
|
2264 | api.mark_read(comments) |
|
2265 | dbsession.flush() |
|
2266 | transaction.commit() |
|
2267 | ||
2268 | self.testapp.authorization = ( |
|
2269 | 'Basic', |
|
2270 | ( |
|
2271 | '[email protected]', |
|
2272 | '[email protected]' |
|
2273 | ) |
|
2274 | ) |
|
2275 | res = self.testapp.get('/api/v2/users/1/workspaces/{}/contents/read_status'.format(workspace.workspace_id), status=200) # nopep8 |
|
2276 | assert res.json_body[0]['content_id'] == firstly_created.content_id |
|
2277 | assert res.json_body[0]['read_by_user'] is True |
|
2278 | self.testapp.put( |
|
2279 | '/api/v2/users/{user_id}/workspaces/{workspace_id}/contents/{content_id}/unread'.format( # nopep8 |
|
2280 | workspace_id=workspace.workspace_id, |
|
2281 | content_id=comments.content_id, |
|
2282 | user_id=admin.user_id, |
|
2283 | ) |
|
2284 | ) |
|
2285 | res = self.testapp.get('/api/v2/users/1/workspaces/{}/contents/read_status'.format(workspace.workspace_id), status=200) # nopep8 |
|
2286 | assert res.json_body[0]['content_id'] == firstly_created.content_id |
|
2287 | assert res.json_body[0]['read_by_user'] is False |
|
2288 | ||
2289 | ||
2290 | class TestUserSetWorkspaceAsRead(FunctionalTest): |
|
@@ 2179-2232 (lines=54) @@ | ||
2176 | assert 'code' in res.json.keys() |
|
2177 | assert res.json_body['code'] == error.INSUFFICIENT_USER_PROFILE |
|
2178 | ||
2179 | def test_api_set_content_as_unread__ok__200__with_comments_read_content(self): |
|
2180 | # init DB |
|
2181 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
2182 | admin = dbsession.query(models.User) \ |
|
2183 | .filter(models.User.email == '[email protected]') \ |
|
2184 | .one() |
|
2185 | workspace_api = WorkspaceApi( |
|
2186 | current_user=admin, |
|
2187 | session=dbsession, |
|
2188 | config=self.app_config |
|
2189 | ||
2190 | ) |
|
2191 | workspace = WorkspaceApi( |
|
2192 | current_user=admin, |
|
2193 | session=dbsession, |
|
2194 | config=self.app_config, |
|
2195 | ).create_workspace( |
|
2196 | 'test workspace', |
|
2197 | save_now=True |
|
2198 | ) |
|
2199 | api = ContentApi( |
|
2200 | current_user=admin, |
|
2201 | session=dbsession, |
|
2202 | config=self.app_config, |
|
2203 | ) |
|
2204 | main_folder = api.create(content_type_list.Folder.slug, workspace, None, 'this is randomized folder', '', True) # nopep8 |
|
2205 | # creation order test |
|
2206 | firstly_created = api.create(content_type_list.Page.slug, workspace, main_folder, 'creation_order_test', '', True) # nopep8 |
|
2207 | comments = api.create_comment(workspace, firstly_created, 'juste a super comment', True) # nopep8 |
|
2208 | api.mark_read(firstly_created) |
|
2209 | api.mark_read(comments) |
|
2210 | dbsession.flush() |
|
2211 | transaction.commit() |
|
2212 | ||
2213 | self.testapp.authorization = ( |
|
2214 | 'Basic', |
|
2215 | ( |
|
2216 | '[email protected]', |
|
2217 | '[email protected]' |
|
2218 | ) |
|
2219 | ) |
|
2220 | res = self.testapp.get('/api/v2/users/1/workspaces/{}/contents/read_status'.format(workspace.workspace_id), status=200) # nopep8 |
|
2221 | assert res.json_body[0]['content_id'] == firstly_created.content_id |
|
2222 | assert res.json_body[0]['read_by_user'] is True |
|
2223 | self.testapp.put( |
|
2224 | '/api/v2/users/{user_id}/workspaces/{workspace_id}/contents/{content_id}/unread'.format( # nopep8 |
|
2225 | workspace_id=workspace.workspace_id, |
|
2226 | content_id=firstly_created.content_id, |
|
2227 | user_id=admin.user_id, |
|
2228 | ) |
|
2229 | ) |
|
2230 | res = self.testapp.get('/api/v2/users/1/workspaces/{}/contents/read_status'.format(workspace.workspace_id), status=200) # nopep8 |
|
2231 | assert res.json_body[0]['content_id'] == firstly_created.content_id |
|
2232 | assert res.json_body[0]['read_by_user'] is False |
|
2233 | ||
2234 | def test_api_set_content_as_unread__ok__200__with_comments_read_comment_only(self): |
|
2235 | # init DB |