|
@@ -1620,6 +1620,69 @@ class TestWorkspaceContents(FunctionalTest):
|
1620
|
1620
|
status=400,
|
1621
|
1621
|
)
|
1622
|
1622
|
|
|
1623
|
+ def test_api__post_content_create_generic_content__err_400__unallowed_content_type(self) -> None: # nopep8
|
|
1624
|
+ """
|
|
1625
|
+ Create generic content
|
|
1626
|
+ """
|
|
1627
|
+ dbsession = get_tm_session(self.session_factory, transaction.manager)
|
|
1628
|
+ admin = dbsession.query(models.User) \
|
|
1629
|
+ .filter(models.User.email == 'admin@admin.admin') \
|
|
1630
|
+ .one()
|
|
1631
|
+ workspace_api = WorkspaceApi(
|
|
1632
|
+ current_user=admin,
|
|
1633
|
+ session=dbsession,
|
|
1634
|
+ config=self.app_config
|
|
1635
|
+ )
|
|
1636
|
+ content_api = ContentApi(
|
|
1637
|
+ current_user=admin,
|
|
1638
|
+ session=dbsession,
|
|
1639
|
+ config=self.app_config
|
|
1640
|
+ )
|
|
1641
|
+ test_workspace = workspace_api.create_workspace(
|
|
1642
|
+ label='test',
|
|
1643
|
+ save_now=True,
|
|
1644
|
+ )
|
|
1645
|
+ folder = content_api.create(
|
|
1646
|
+ label='test-folder',
|
|
1647
|
+ content_type_slug=CONTENT_TYPES.Folder.slug,
|
|
1648
|
+ workspace=test_workspace,
|
|
1649
|
+ do_save=False,
|
|
1650
|
+ do_notify=False
|
|
1651
|
+ )
|
|
1652
|
+ content_api.set_allowed_content(folder, [CONTENT_TYPES.Folder.slug])
|
|
1653
|
+ content_api.save(folder)
|
|
1654
|
+ transaction.commit()
|
|
1655
|
+ self.testapp.authorization = (
|
|
1656
|
+ 'Basic',
|
|
1657
|
+ (
|
|
1658
|
+ 'admin@admin.admin',
|
|
1659
|
+ 'admin@admin.admin'
|
|
1660
|
+ )
|
|
1661
|
+ )
|
|
1662
|
+ # unallowed_content_type
|
|
1663
|
+ params = {
|
|
1664
|
+ 'label': 'GenericCreatedContent',
|
|
1665
|
+ 'content_type': 'markdownpage',
|
|
1666
|
+ 'parent_id': folder.content_id
|
|
1667
|
+ }
|
|
1668
|
+ res = self.testapp.post_json(
|
|
1669
|
+ '/api/v2/workspaces/{workspace_id}/contents'.format(workspace_id=test_workspace.workspace_id),
|
|
1670
|
+ params=params,
|
|
1671
|
+ status=400,
|
|
1672
|
+ )
|
|
1673
|
+
|
|
1674
|
+ # allowed_content_type
|
|
1675
|
+ params = {
|
|
1676
|
+ 'label': 'GenericCreatedContent',
|
|
1677
|
+ 'content_type': 'folder',
|
|
1678
|
+ 'parent_id': folder.content_id
|
|
1679
|
+ }
|
|
1680
|
+ res = self.testapp.post_json(
|
|
1681
|
+ '/api/v2/workspaces/{workspace_id}/contents'.format(workspace_id=test_workspace.workspace_id),
|
|
1682
|
+ params=params,
|
|
1683
|
+ status=200,
|
|
1684
|
+ )
|
|
1685
|
+
|
1623
|
1686
|
def test_api_put_move_content__ok_200__nominal_case(self):
|
1624
|
1687
|
"""
|
1625
|
1688
|
Move content
|