@@ 1289-1387 (lines=99) @@ | ||
1286 | status=400, |
|
1287 | ) |
|
1288 | ||
1289 | def test_api_set_content_as_read__ok__200__user_itself(self): |
|
1290 | # init DB |
|
1291 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
1292 | admin = dbsession.query(models.User) \ |
|
1293 | .filter(models.User.email == '[email protected]') \ |
|
1294 | .one() |
|
1295 | workspace_api = WorkspaceApi( |
|
1296 | current_user=admin, |
|
1297 | session=dbsession, |
|
1298 | config=self.app_config |
|
1299 | ||
1300 | ) |
|
1301 | workspace = WorkspaceApi( |
|
1302 | current_user=admin, |
|
1303 | session=dbsession, |
|
1304 | config=self.app_config, |
|
1305 | ).create_workspace( |
|
1306 | 'test workspace', |
|
1307 | save_now=True |
|
1308 | ) |
|
1309 | uapi = UserApi( |
|
1310 | current_user=admin, |
|
1311 | session=dbsession, |
|
1312 | config=self.app_config, |
|
1313 | ) |
|
1314 | gapi = GroupApi( |
|
1315 | current_user=admin, |
|
1316 | session=dbsession, |
|
1317 | config=self.app_config, |
|
1318 | ) |
|
1319 | groups = [gapi.get_one_with_name('users')] |
|
1320 | test_user = uapi.create_user( |
|
1321 | email='[email protected]', |
|
1322 | password='pass', |
|
1323 | name='bob', |
|
1324 | groups=groups, |
|
1325 | timezone='Europe/Paris', |
|
1326 | lang='fr', |
|
1327 | do_save=True, |
|
1328 | do_notify=False, |
|
1329 | ) |
|
1330 | rapi = RoleApi( |
|
1331 | current_user=admin, |
|
1332 | session=dbsession, |
|
1333 | config=self.app_config, |
|
1334 | ) |
|
1335 | rapi.create_one(test_user, workspace, UserRoleInWorkspace.READER, False) |
|
1336 | api = ContentApi( |
|
1337 | current_user=admin, |
|
1338 | session=dbsession, |
|
1339 | config=self.app_config, |
|
1340 | ) |
|
1341 | api2 = ContentApi( |
|
1342 | current_user=test_user, |
|
1343 | session=dbsession, |
|
1344 | config=self.app_config, |
|
1345 | ) |
|
1346 | main_folder = api.create(CONTENT_TYPES.Folder.slug, workspace, None, 'this is randomized folder', '', True) # nopep8 |
|
1347 | # creation order test |
|
1348 | firstly_created = api.create(CONTENT_TYPES.Page.slug, workspace, main_folder, 'creation_order_test', '', True) # nopep8 |
|
1349 | api.mark_unread(firstly_created) |
|
1350 | api2.mark_unread(firstly_created) |
|
1351 | dbsession.flush() |
|
1352 | transaction.commit() |
|
1353 | ||
1354 | self.testapp.authorization = ( |
|
1355 | 'Basic', |
|
1356 | ( |
|
1357 | '[email protected]', |
|
1358 | 'pass' |
|
1359 | ) |
|
1360 | ) |
|
1361 | # before |
|
1362 | res = self.testapp.get('/api/v2/users/{user_id}/workspaces/{workspace_id}/contents/read_status'.format( # nopep8 |
|
1363 | user_id=test_user.user_id, |
|
1364 | workspace_id=workspace.workspace_id |
|
1365 | ), |
|
1366 | status=200 |
|
1367 | ) |
|
1368 | assert res.json_body[0]['content_id'] == firstly_created.content_id |
|
1369 | assert res.json_body[0]['read_by_user'] is False |
|
1370 | ||
1371 | # read |
|
1372 | self.testapp.put( |
|
1373 | '/api/v2/users/{user_id}/workspaces/{workspace_id}/contents/{content_id}/read'.format( # nopep8 |
|
1374 | workspace_id=workspace.workspace_id, |
|
1375 | content_id=firstly_created.content_id, |
|
1376 | user_id=test_user.user_id, |
|
1377 | ) |
|
1378 | ) |
|
1379 | # after |
|
1380 | res = self.testapp.get('/api/v2/users/{user_id}/workspaces/{workspace_id}/contents/read_status'.format( # nopep8 |
|
1381 | user_id=test_user.user_id, |
|
1382 | workspace_id=workspace.workspace_id |
|
1383 | ), |
|
1384 | status=200 |
|
1385 | ) |
|
1386 | assert res.json_body[0]['content_id'] == firstly_created.content_id |
|
1387 | assert res.json_body[0]['read_by_user'] is True |
|
1388 | ||
1389 | def test_api_set_content_as_read__ok__403__other_user(self): |
|
1390 | # init DB |
|
@@ 1864-1958 (lines=95) @@ | ||
1861 | status=400, |
|
1862 | ) |
|
1863 | ||
1864 | def test_api_set_content_as_unread__ok__200__user_itself(self): |
|
1865 | # init DB |
|
1866 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
1867 | admin = dbsession.query(models.User) \ |
|
1868 | .filter(models.User.email == '[email protected]') \ |
|
1869 | .one() |
|
1870 | workspace_api = WorkspaceApi( |
|
1871 | current_user=admin, |
|
1872 | session=dbsession, |
|
1873 | config=self.app_config |
|
1874 | ||
1875 | ) |
|
1876 | workspace = WorkspaceApi( |
|
1877 | current_user=admin, |
|
1878 | session=dbsession, |
|
1879 | config=self.app_config, |
|
1880 | ).create_workspace( |
|
1881 | 'test workspace', |
|
1882 | save_now=True |
|
1883 | ) |
|
1884 | uapi = UserApi( |
|
1885 | current_user=admin, |
|
1886 | session=dbsession, |
|
1887 | config=self.app_config, |
|
1888 | ) |
|
1889 | gapi = GroupApi( |
|
1890 | current_user=admin, |
|
1891 | session=dbsession, |
|
1892 | config=self.app_config, |
|
1893 | ) |
|
1894 | groups = [gapi.get_one_with_name('users')] |
|
1895 | test_user = uapi.create_user( |
|
1896 | email='[email protected]', |
|
1897 | password='pass', |
|
1898 | name='bob', |
|
1899 | groups=groups, |
|
1900 | timezone='Europe/Paris', |
|
1901 | lang='fr', |
|
1902 | do_save=True, |
|
1903 | do_notify=False, |
|
1904 | ) |
|
1905 | rapi = RoleApi( |
|
1906 | current_user=admin, |
|
1907 | session=dbsession, |
|
1908 | config=self.app_config, |
|
1909 | ) |
|
1910 | rapi.create_one(test_user, workspace, UserRoleInWorkspace.READER, False) |
|
1911 | api = ContentApi( |
|
1912 | current_user=admin, |
|
1913 | session=dbsession, |
|
1914 | config=self.app_config, |
|
1915 | ) |
|
1916 | api2 = ContentApi( |
|
1917 | current_user=test_user, |
|
1918 | session=dbsession, |
|
1919 | config=self.app_config, |
|
1920 | ) |
|
1921 | main_folder = api.create(CONTENT_TYPES.Folder.slug, workspace, None, 'this is randomized folder', '', True) # nopep8 |
|
1922 | # creation order test |
|
1923 | firstly_created = api.create(CONTENT_TYPES.Page.slug, workspace, main_folder, 'creation_order_test', '', True) # nopep8 |
|
1924 | api.mark_read(firstly_created) |
|
1925 | api2.mark_read(firstly_created) |
|
1926 | dbsession.flush() |
|
1927 | transaction.commit() |
|
1928 | ||
1929 | self.testapp.authorization = ( |
|
1930 | 'Basic', |
|
1931 | ( |
|
1932 | '[email protected]', |
|
1933 | 'pass' |
|
1934 | ) |
|
1935 | ) |
|
1936 | # before |
|
1937 | res = self.testapp.get('/api/v2/users/{user_id}/workspaces/{workspace_id}/contents/read_status'.format( # nopep8 |
|
1938 | user_id=test_user.user_id, |
|
1939 | workspace_id=workspace.workspace_id |
|
1940 | ), status=200) |
|
1941 | assert res.json_body[0]['content_id'] == firstly_created.content_id |
|
1942 | assert res.json_body[0]['read_by_user'] is True |
|
1943 | ||
1944 | # unread |
|
1945 | self.testapp.put( |
|
1946 | '/api/v2/users/{user_id}/workspaces/{workspace_id}/contents/{content_id}/unread'.format( # nopep8 |
|
1947 | workspace_id=workspace.workspace_id, |
|
1948 | content_id=firstly_created.content_id, |
|
1949 | user_id=test_user.user_id, |
|
1950 | ) |
|
1951 | ) |
|
1952 | # after |
|
1953 | res = self.testapp.get('/api/v2/users/{user_id}/workspaces/{workspace_id}/contents/read_status'.format( # nopep8 |
|
1954 | user_id=test_user.user_id, |
|
1955 | workspace_id=workspace.workspace_id |
|
1956 | ), status=200) |
|
1957 | assert res.json_body[0]['content_id'] == firstly_created.content_id |
|
1958 | assert res.json_body[0]['read_by_user'] is False |
|
1959 | ||
1960 | def test_api_set_content_as_unread__err__403__other_user(self): |
|
1961 | # init DB |