示例#1
0
    def setUpClass(self):

        self.repo = KnowledgeRepository.for_uri('tests/test_repo',
                                                auto_create=True)
        self.app = self.repo.get_app(config='tests/config_server.py')
        self.app.repository.config.editors = ['knowledge_editors']
        self.client = self.app.test_client()

        self.knowledge_username = '******'
        self.post_path = 'tests/test_email_functionality'
        self.thumbnail = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX/TQBcNTh/AAAAAXR' \
                         'STlPM0jRW/QAAAApJREFUeJxjYgAAAAYAAzY3fKgAAAAASUVORK5CYII='  # Red pixel
        kp = KnowledgePost(self.post_path)

        headers = {
            'title': 'Test Email Functionality',
            'authors': [self.knowledge_username],
            'tags': ['test_tag'],
            'tldr': 'This is the test tldr for the post',
            'thumbnail': 'data:image/png;base64,{}'.format(self.thumbnail),
            'created_at': datetime.date.today(),
            'updated_at': datetime.date.today()
        }
        kp.write(md='Test Text', headers=headers)

        # manual re-index
        with self.app.app_context():
            self.repo.add(kp, message='test commit message')

            post = Post()
            db_session.add(post)
            post.update_metadata_from_kp(kp)
            db_session.commit()

            self.post_id = post.id
    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_USER_IDENTIFIER_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
示例#3
0
    def setUpClass(self):

        self.repo = KnowledgeRepository.for_uri('tests/test_repo',
                                                auto_create=True)
        self.app = self.repo.get_app(config='tests/config_server.py')
        self.app.repository.config.editors = ['knowledge_editors']
        self.client = self.app.test_client()

        self.knowledge_username = '******'
        self.post_path = 'tests/test_email_functionality'
        kp = KnowledgePost(self.post_path)

        headers = {
            'title': 'Test Email Functionality',
            'authors': [self.knowledge_username],
            'tags': ['test_tag'],
            'tldr': 'This is the test tldr for the post',
            'created_at': datetime.date.today(),
            'updated_at': datetime.date.today()
        }
        kp.write(md='Test Text', headers=headers)
        self.repo.add(kp, message='test commit message')

        # manual re-index
        with self.app.app_context():
            post = Post()
            db_session.add(post)
            post.update_metadata_from_kp(kp)
            db_session.commit()
            self.post_id = post.id
示例#4
0
    def setUp(self):
        """Set up the TagsTest Class by instantiating a tag."""
        self.repo = KnowledgeRepository.for_uri('tests/test_repo', auto_create=True)
        self.app = self.repo.get_app(config='tests/config_server.py')
        self.client = self.app.test_client()

        self.knowledge_username = '******'
        with self.app.app_context():
            user = User(identifier=self.knowledge_username)
            if user.id is None:
                db_session.commit()
            self.user_id = user.id

            # we'll create a tag for the purpose of tag testing
            test_run = datetime.datetime.now().strftime('%Y-%m-%d')
            tag = Tag(name='test/tag_' + test_run)
            db_session.commit()
            TagsTest.tag_id = tag.id
            TagsTest.tag_name = tag.name
            TagsTest.user_id = self.user_id

            # We need an example post as well to test some of the
            # add/delete/rename functionality
            example_post = (db_session.query(Post).first())
            TagsTest.post_path = example_post.path

        self.headers = {self.app.config['AUTH_USER_IDENTIFIER_REQUEST_HEADER']: self.knowledge_username}
示例#5
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.headers = {}
     self.data = []
示例#6
0
    def setUp(self):
        """Set up the TagsTest Class by instantiating a tag."""
        self.repo = KnowledgeRepository.for_uri('tests/test_repo',
                                                auto_create=True)
        self.app = self.repo.get_app(config='tests/config_server.py')
        self.client = self.app.test_client()

        self.knowledge_username = '******'
        with self.app.app_context():
            user = User(identifier=self.knowledge_username)
            if user.id is None:
                db_session.commit()
            self.user_id = user.id

            # we'll create a tag for the purpose of tag testing
            test_run = datetime.datetime.now().strftime('%Y-%m-%d')
            tag = Tag(name='test/tag_' + test_run)
            db_session.commit()
            TagsTest.tag_id = tag.id
            TagsTest.tag_name = tag.name
            TagsTest.user_id = self.user_id

            # We need an example post as well to test some of the
            # add/delete/rename functionality
            example_post = (db_session.query(Post).first())
            TagsTest.post_path = example_post.path

        self.headers = {
            self.app.config['AUTH_USER_IDENTIFIER_REQUEST_HEADER']:
            self.knowledge_username
        }
示例#7
0
    def setUpClass(self):

        self.repo = KnowledgeRepository.for_uri('tests/test_repo', auto_create=True)
        self.app = self.repo.get_app(config='tests/config_server.py')
        self.app.repository.config.editors = ['knowledge_editors']
        self.client = self.app.test_client()

        self.knowledge_username = '******'
        self.post_path = 'tests/test_email_functionality'
        kp = KnowledgePost(self.post_path)

        headers = {'title': 'Test Email Functionality',
                   'authors': [self.knowledge_username],
                   'tags': ['test_tag'],
                   'tldr': 'This is the test tldr for the post',
                   'created_at': datetime.date.today(),
                   'updated_at': datetime.date.today()}
        kp.write(md='Test Text', headers=headers)

        # manual re-index
        with self.app.app_context():
            self.repo.add(kp, message='test commit message')

            post = Post()
            db_session.add(post)
            post.update_metadata_from_kp(kp)
            db_session.commit()

            self.post_id = post.id
示例#8
0
    def setUp(self):
        self.repo = KnowledgeRepository.for_uri('tests/test_repo',
                                                auto_create=True)
        self.app = self.repo.get_app(config='tests/config_server.py')
        self.client = self.app.test_client()

        with self.app.app_context():
            # for this test, pick one post
            post = (db_session.query(Post).filter(Post.is_published).first())
            self.post_id = post.id
            self.post_rendered_url = '/render?markdown={}'.format(post.path)
示例#9
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.headers = {}

        self.knowledge_username = '******'
        username_request_header = self.repo_app.config.get("AUTH_USER_IDENTIFIER_REQUEST_HEADER")
        self.headers = {
            username_request_header: self.knowledge_username
        }
示例#10
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.headers = {}

        self.knowledge_username = '******'
        username_request_header = self.repo_app.config.get(
            "AUTH_USER_IDENTIFIER_REQUEST_HEADER")
        self.headers = {username_request_header: self.knowledge_username}
    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(identifier=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_USER_IDENTIFIER_REQUEST_HEADER")
        self.headers = {username_request_header: self.knowledge_username}
示例#12
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(identifier=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_USER_IDENTIFIER_REQUEST_HEADER")
        self.headers = {
            username_request_header: self.knowledge_username
        }
示例#13
0
    def setUpClass(self):
        self.repo = KnowledgeRepository.for_uri('tests/test_repo',
                                                auto_create=True)
        self.app = self.repo.get_app(config='tests/config_server.py')
        self.app.repository.config.editors = ['knowledge_editors']
        self.client = self.app.test_client()

        self.knowledge_username = '******'
        # this creates a user
        with self.app.app_context():
            User(username=self.knowledge_username)

            web_post = Post(title='test_webpost')
            git_post = (db_session.query(Post).first())

            db_session.add(web_post)
            web_post.authors = ['test_author']

            git_post.tags = ['test_tag']

            db_session.commit()

            self.web_post_id = web_post.id
            self.git_post_id = git_post.id
示例#14
0
 def setUp(self):
     self.repo = KnowledgeRepository.for_uri('tests/test_repo', auto_create=True)
     self.app = self.repo.get_app(config='tests/config_server.py').test_client()
     self.headers = {}
示例#15
0
 def get_app():
     return KnowledgeRepository.for_uri(uris).get_app(db_uri=db_uri,
                                                      debug=debug,
                                                      config=config,
                                                      **kwargs)