Ejemplo n.º 1
0
 def test_list(self):
     # Create mock issue
     discussion = data_mocking.create_discussion(
         {
             'project_id': self.project.id,
             'name': 'test',
             'title': 'test',
         },
         self.session,
     )
     comment1 = data_mocking.create_discussion_comment(
         {
             'discussion_id': discussion.id,
             'project_id': self.project.id,
             'user_id': self.project_data['users'][0].id,
             'content': 'test'
         }, self.session)
     comment2 = data_mocking.create_discussion_comment(
         {
             'discussion_id': discussion.id,
             'project_id': self.project.id,
             'user_id': self.project_data['users'][0].id,
             'content': 'test2'
         }, self.session)
     comments = DiscussionComment.list(session=self.session,
                                       project_id=self.project.id,
                                       discussion_id=discussion.id)
     self.assertIsNotNone(comments)
     self.assertEqual(len(comments), 2)
     ids = [comment.id for comment in comments]
     self.assertTrue(comment1.id in ids)
     self.assertTrue(comment2.id in ids)
Ejemplo n.º 2
0
def list_discussion_comments_core(session,
                                  project,
                                  discussion,
                                  log=regular_log.default()):
    """
        List comments of the discussion. At this point we assume data has been validated so no extra checks are
        done to the input data.
    :param session:
    :param log:
    :param member:
    :param project:
    :param discussion:
    :param content:
    :return:
    """
    comments = DiscussionComment.list(session=session,
                                      project_id=project.id,
                                      discussion_id=discussion.id)

    comment_data = [comment.serialize() for comment in comments]
    return comment_data, log