@@ 1599-1672 (lines=74) @@ | ||
1596 | assert content['last_modifier'] == content['author'] |
|
1597 | assert content['raw_content'] == '<p> Le nouveau contenu </p>' |
|
1598 | ||
1599 | def test_api__get_file_revisions__ok_200__nominal_case( |
|
1600 | self |
|
1601 | ) -> None: |
|
1602 | """ |
|
1603 | Get file revisions |
|
1604 | """ |
|
1605 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
1606 | admin = dbsession.query(models.User) \ |
|
1607 | .filter(models.User.email == '[email protected]') \ |
|
1608 | .one() |
|
1609 | workspace_api = WorkspaceApi( |
|
1610 | current_user=admin, |
|
1611 | session=dbsession, |
|
1612 | config=self.app_config |
|
1613 | ) |
|
1614 | content_api = ContentApi( |
|
1615 | current_user=admin, |
|
1616 | session=dbsession, |
|
1617 | config=self.app_config |
|
1618 | ) |
|
1619 | business_workspace = workspace_api.get_one(1) |
|
1620 | tool_folder = content_api.get_one(1, content_type=CONTENT_TYPES.Any_SLUG) |
|
1621 | test_file = content_api.create( |
|
1622 | content_type_slug=CONTENT_TYPES.File.slug, |
|
1623 | workspace=business_workspace, |
|
1624 | parent=tool_folder, |
|
1625 | label='Test file', |
|
1626 | do_save=False, |
|
1627 | do_notify=False, |
|
1628 | ) |
|
1629 | test_file.file_extension = '.txt' |
|
1630 | test_file.depot_file = FileIntent( |
|
1631 | b'Test file', |
|
1632 | 'Test_file.txt', |
|
1633 | 'text/plain', |
|
1634 | ) |
|
1635 | content_api.update_content(test_file, 'Test_file', '<p>description</p>') # nopep8 |
|
1636 | dbsession.flush() |
|
1637 | transaction.commit() |
|
1638 | ||
1639 | self.testapp.authorization = ( |
|
1640 | 'Basic', |
|
1641 | ( |
|
1642 | '[email protected]', |
|
1643 | '[email protected]' |
|
1644 | ) |
|
1645 | ) |
|
1646 | res = self.testapp.get( |
|
1647 | '/api/v2/workspaces/1/files/{}/revisions'.format(test_file.content_id), # nopep8 |
|
1648 | status=200 |
|
1649 | ) |
|
1650 | revisions = res.json_body |
|
1651 | assert len(revisions) == 1 |
|
1652 | revision = revisions[0] |
|
1653 | assert revision['content_type'] == 'file' |
|
1654 | assert revision['content_id'] == test_file.content_id |
|
1655 | assert revision['is_archived'] is False |
|
1656 | assert revision['is_deleted'] is False |
|
1657 | assert revision['label'] == 'Test_file' |
|
1658 | assert revision['parent_id'] == 1 |
|
1659 | assert revision['show_in_ui'] is True |
|
1660 | assert revision['slug'] == 'test-file' |
|
1661 | assert revision['status'] == 'open' |
|
1662 | assert revision['workspace_id'] == 1 |
|
1663 | assert revision['revision_id'] |
|
1664 | assert revision['sub_content_types'] |
|
1665 | # TODO - G.M - 2018-06-173 - Test with real comments |
|
1666 | assert revision['comment_ids'] == [] |
|
1667 | # TODO - G.M - 2018-06-173 - check date format |
|
1668 | assert revision['created'] |
|
1669 | assert revision['author'] |
|
1670 | assert revision['author']['user_id'] == 1 |
|
1671 | assert revision['author']['avatar_url'] is None |
|
1672 | assert revision['author']['public_name'] == 'Global manager' |
|
1673 | ||
1674 | def test_api__set_file_status__ok_200__nominal_case(self) -> None: |
|
1675 | """ |
|
@@ 1272-1342 (lines=71) @@ | ||
1269 | ||
1270 | fixtures = [BaseFixture, ContentFixtures] |
|
1271 | ||
1272 | def test_api__get_file__ok_200__nominal_case(self) -> None: |
|
1273 | """ |
|
1274 | Get one file of a content |
|
1275 | """ |
|
1276 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
1277 | admin = dbsession.query(models.User) \ |
|
1278 | .filter(models.User.email == '[email protected]') \ |
|
1279 | .one() |
|
1280 | workspace_api = WorkspaceApi( |
|
1281 | current_user=admin, |
|
1282 | session=dbsession, |
|
1283 | config=self.app_config |
|
1284 | ) |
|
1285 | content_api = ContentApi( |
|
1286 | current_user=admin, |
|
1287 | session=dbsession, |
|
1288 | config=self.app_config |
|
1289 | ) |
|
1290 | business_workspace = workspace_api.get_one(1) |
|
1291 | tool_folder = content_api.get_one(1, content_type=CONTENT_TYPES.Any_SLUG) |
|
1292 | test_file = content_api.create( |
|
1293 | content_type_slug=CONTENT_TYPES.File.slug, |
|
1294 | workspace=business_workspace, |
|
1295 | parent=tool_folder, |
|
1296 | label='Test file', |
|
1297 | do_save=False, |
|
1298 | do_notify=False, |
|
1299 | ) |
|
1300 | test_file.file_extension = '.txt' |
|
1301 | test_file.depot_file = FileIntent( |
|
1302 | b'Test file', |
|
1303 | 'Test_file.txt', |
|
1304 | 'text/plain', |
|
1305 | ) |
|
1306 | content_api.update_content(test_file, 'Test_file', '<p>description</p>') # nopep8 |
|
1307 | dbsession.flush() |
|
1308 | transaction.commit() |
|
1309 | ||
1310 | self.testapp.authorization = ( |
|
1311 | 'Basic', |
|
1312 | ( |
|
1313 | '[email protected]', |
|
1314 | '[email protected]' |
|
1315 | ) |
|
1316 | ) |
|
1317 | res = self.testapp.get( |
|
1318 | '/api/v2/workspaces/1/files/{}'.format(test_file.content_id), |
|
1319 | status=200 |
|
1320 | ) |
|
1321 | content = res.json_body |
|
1322 | assert content['content_type'] == 'file' |
|
1323 | assert content['content_id'] == test_file.content_id |
|
1324 | assert content['is_archived'] is False |
|
1325 | assert content['is_deleted'] is False |
|
1326 | assert content['label'] == 'Test_file' |
|
1327 | assert content['parent_id'] == 1 |
|
1328 | assert content['show_in_ui'] is True |
|
1329 | assert content['slug'] == 'test-file' |
|
1330 | assert content['status'] == 'open' |
|
1331 | assert content['workspace_id'] == 1 |
|
1332 | assert content['current_revision_id'] |
|
1333 | # TODO - G.M - 2018-06-173 - check date format |
|
1334 | assert content['created'] |
|
1335 | assert content['author'] |
|
1336 | assert content['author']['user_id'] == 1 |
|
1337 | assert content['author']['avatar_url'] is None |
|
1338 | assert content['author']['public_name'] == 'Global manager' |
|
1339 | # TODO - G.M - 2018-06-173 - check date format |
|
1340 | assert content['modified'] |
|
1341 | assert content['last_modifier'] == content['author'] |
|
1342 | assert content['raw_content'] == '<p>description</p>' # nopep8 |
|
1343 | ||
1344 | def test_api__get_files__err_400__wrong_content_type(self) -> None: |
|
1345 | """ |