def setUpClass(cls):
        """Set up the WebEditor Test Class.

        Create a webpost and a testuser
        """
        cls.repo = KnowledgeRepository.for_uri('sqlite:///:memory::test_posts',
                                               auto_create=True)
        cls.repo.config.editors = ['test_knowledge_editor']
        cls.app = cls.repo.get_app(config='tests/config_server.py')
        cls.app.config['AUTH_USERNAME_REQUEST_HEADER'] = 'user_header'
        cls.app.config['DEBUG'] = True
        cls.client = cls.app.test_client()

        cls.post_path = 'webeditor/misc/test_webeditor_functionality.kp'
        kp = KnowledgePost(cls.post_path)

        headers = {
            'title': 'Test Webeditor Functionality',
            'authors': ['webeditor_test_user'],
            'tldr': 'This is the test tldr for the webpost.',
            'created_at': datetime.date.today(),
            'updated_at': datetime.date.today()
        }
        kp.write(md='Test Text', headers=headers)
        cls.repo.add(kp)

        # manual re-index
        with cls.app.app_context():
            post = Post()
            db_session.add(post)
            post.update_metadata_from_kp(kp)
            db_session.commit()
            cls.post_id = post.id
Exemplo n.º 2
0
    def setUp(self):
        self.repo = KnowledgeRepository.for_uri('tests/test_repo', auto_create=True)
        self.repo_app = self.repo.get_app(config='tests/config_server.py')
        self.app = self.repo_app.test_client()

        self.knowledge_username = '******'
        with self.repo_app.app_context():
            user = User(username=self.knowledge_username)
            if user.id is None:
                db_session.commit()
            self.user_id = user.id
        username_request_header = self.repo_app.config.get(
            "AUTH_USERNAME_REQUEST_HEADER")
        self.headers = {
            username_request_header: self.knowledge_username
        }