Beispiel #1
0
    def _create_content_and_test(self, name, workspace, *args,
                                 **kwargs) -> Content:
        """
        All extra parameters (*args, **kwargs) are for Content init
        :return: Created Content instance
        """
        content = Content(*args, **kwargs)
        content.label = name
        content.workspace = workspace
        self.session.add(content)
        self.session.flush()

        content_api = ContentApi(
            current_user=None,
            session=self.session,
            config=self.app_config,
        )
        eq_(
            1,
            content_api.get_canonical_query().filter(
                Content.label == name).count())
        return content_api.get_canonical_query().filter(
            Content.label == name).one()
 def test_children(self):
     admin = self.session.query(User).filter(
         User.email == '*****@*****.**').one()
     self._create_thread_and_test(workspace_name='workspace_1',
                                  folder_name='folder_1',
                                  thread_name='thread_1',
                                  user=admin)
     workspace = self.session.query(Workspace).filter(
         Workspace.label == 'workspace_1').one()
     content_api = ContentApi(
         session=self.session,
         current_user=admin,
         config=self.app_config,
     )
     folder = content_api.get_canonical_query().filter(
         Content.label == 'folder_1').one()
     eq_([
         folder,
     ], list(workspace.get_valid_children()))