예제 #1
0
파일: test_stat.py 프로젝트: leeccong/code
    def test_issue_stat(self):
        issue_rs = get_all_issue()
        assert len(issue_rs) == 0
        issue_open_count = len(filter(lambda x: x[1] is None, issue_rs))
        assert issue_open_count == 0
        assert len(issue_rs) - issue_open_count == 0

        i1 = Issue.add('test1', 'test des1', 'testuser1', 'assignee')
        issue_rs = get_all_issue()
        assert len(issue_rs) == 1
        issue_open_count = len(filter(lambda x: x[1] is None, issue_rs))
        assert issue_open_count == 1
        assert len(issue_rs) - issue_open_count == 0

        i2 = Issue.add('test2', 'test des1', 'testuser1', 'assignee')
        i3 = Issue.add('test3', 'test des1', 'testuser2', 'assignee')
        issue_rs = get_all_issue()
        assert len(issue_rs) == 3
        issue_open_count = len(filter(lambda x: x[1] is None, issue_rs))
        assert issue_open_count == 3
        assert len(issue_rs) - issue_open_count == 0

        i1.close('testuser1')
        issue_rs = get_all_issue()
        assert len(issue_rs) == 3
        issue_open_count = len(filter(lambda x: x[1] is None, issue_rs))
        assert issue_open_count == 2
        assert len(issue_rs) - issue_open_count == 1

        issue_comment_count = get_issue_comment_count()
        assert issue_comment_count == 0
        IssueComment.add(i2.id, 'content', 'test')
        IssueComment.add(i3.id, 'content', 'test1')
        issue_comment_count = get_issue_comment_count()
        assert issue_comment_count == 2
 def setUp(self):
     super(ProjectIssueCommentsTest, self).setUp()
     project_name = "code"
     product_name = "fire"
     summary = "test"
     owner_id = "lisong_intern"
     delete_project(project_name)
     project = CodeDoubanProject.add(
         project_name,
         owner_id=owner_id,
         summary=summary,
         product=product_name
     )
     self.project = project
     title = "test title"
     description = "test desc"
     creator = "test"
     issue = ProjectIssue.add(
         title,
         description,
         creator,
         project=self.project.id
     )
     self.issue = issue
     self.project = project
     self.comment1 = IssueComment.add(
         self.issue.issue_id, 'content1', 'test1')
     self.comment2 = IssueComment.add(
         self.issue.issue_id, 'content2', 'test2')
     self.api_token = self.create_api_token('test1')
     self.api_token2 = self.create_api_token('test2')
예제 #3
0
 def test_update_comment(self):
     i = Issue.add('test', 'test description', 'test', 'assignee')
     c = IssueComment.add(i.id, 'content', 'test')
     c.update('content1')
     c = IssueComment.get(c.id)
     assert c.issue_id == i.id
     assert c.content == 'content1'
     assert c.author_id == 'test'
예제 #4
0
 def test_update_comment(self):
     i = Issue.add('test', 'test description', 'test', 'assignee')
     c = IssueComment.add(i.id, 'content', 'test')
     c.update('content1')
     c = IssueComment.get(c.id)
     assert c.issue_id == i.id
     assert c.content == 'content1'
     assert c.author_id == 'test'
예제 #5
0
 def test_get_single_issue(self):
     title = "test title"
     description = "test desc"
     creator = "test"
     issue = ProjectIssue.add(title, description, creator, project=self.project.id)
     IssueComment.add(issue.issue_id, "content", "test")
     ret = self.app.get("/api/%s/issues/%s/" % (self.project.name, issue.number), status=200).json
     self.assertEquals(ret["title"], title)
     self.assertEquals(ret["description"], description)
     self.assertEquals(ret["creator"], creator)
     self.assertEquals(ret["project"], self.project.name)
     self.assertEquals(ret["comments"], 1)
예제 #6
0
    def test_get_comment(self):
        i = Issue.add('test', 'test description', 'test', 'assignee')
        c = IssueComment.add(i.id, 'content', 'test')
        c = IssueComment.get(c.id)
        assert isinstance(c, IssueComment)
        assert c.issue_id == i.id
        assert c.content == 'content'
        assert c.author_id == 'test'

        c = IssueComment.add(i.id, 'content', 'test')
        cs = IssueComment.gets_by_issue_id(i.id)
        assert all([isinstance(t, IssueComment) for t in cs])
        assert len(cs) == 2
예제 #7
0
    def test_get_comment(self):
        i = Issue.add('test', 'test description', 'test', 'assignee')
        c = IssueComment.add(i.id, 'content', 'test')
        c = IssueComment.get(c.id)
        assert isinstance(c, IssueComment)
        assert c.issue_id == i.id
        assert c.content == 'content'
        assert c.author_id == 'test'

        c = IssueComment.add(i.id, 'content', 'test')
        cs = IssueComment.gets_by_issue_id(i.id)
        assert all([isinstance(t, IssueComment) for t in cs])
        assert len(cs) == 2
예제 #8
0
 def test_add_comment(self):
     i = Issue.add('test', 'test description', 'test', 'assignee')
     c = IssueComment.add(i.id, 'content', 'test')
     assert isinstance(c, IssueComment)
     assert c.issue_id == i.id
     assert c.content == 'content'
     assert c.author_id == 'test'
예제 #9
0
def format_issue_comment_info(**kw):
    from vilya.models.issue_comment import IssueComment
    issue_id = kw['issue_id']
    author = kw['author']
    content = kw['content']
    comment_id = kw['comment_id']

    issue = get_issue_by_issue_id(issue_id)
    target = issue.target

    issue_comment = IssueComment.get(comment_id)
    text = trunc_utf8(content, 50)
    uid = "issue-comment-%s-%s-%s-%s" % (issue.target_type, target.id,
                                         issue.number, issue_comment.number)
    type = 'issue_comment'
    data = dict(
        date=datetime.now(),
        url="%s#comment-%s" % (issue.url, issue_comment.number),
        number=issue.number,
        title=issue.title,
        target_name="%s" % target.name,
        target_url="%s" % target.url,
        receiver=issue.creator_id,
        author=author,
        text=text,
        uid=uid,
        type=type,
    )
    return data
예제 #10
0
파일: team.py 프로젝트: leeccong/code
 def _q_lookup(self, request, comment_id):
     comment = IssueComment.get(comment_id)
     if not comment:
         raise TraversalError("Unable to find issue comment %s" % comment_id)
     else:
         self.comment = comment
         return self
예제 #11
0
 def test_add_comment(self):
     i = Issue.add('test', 'test description', 'test', 'assignee')
     c = IssueComment.add(i.id, 'content', 'test')
     assert isinstance(c, IssueComment)
     assert c.issue_id == i.id
     assert c.content == 'content'
     assert c.author_id == 'test'
예제 #12
0
파일: issue.py 프로젝트: jackfrued/code-1
 def _q_lookup(self, request, comment_id):
     comment = IssueComment.get(comment_id)
     if not comment:
         raise TraversalError("Unable to find issue comment %s" %
                              comment_id)
     else:
         self.comment = comment
         return self
예제 #13
0
 def test_get_single_issue(self):
     title = "test title"
     description = "test desc"
     creator = "test"
     issue = ProjectIssue.add(title,
                              description,
                              creator,
                              project=self.project.id)
     IssueComment.add(issue.issue_id, 'content', 'test')
     ret = self.app.get("/api/%s/issues/%s/" %
                        (self.project.name, issue.number),
                        status=200).json
     self.assertEquals(ret['title'], title)
     self.assertEquals(ret['description'], description)
     self.assertEquals(ret['creator'], creator)
     self.assertEquals(ret['project'], self.project.name)
     self.assertEquals(ret['comments'], 1)
예제 #14
0
파일: team.py 프로젝트: leeccong/code
 def edit(self, request):
     if request.method == "POST":
         user = request.user
         current_user = request.user
         if self.comment.author_id != user.username:
             raise AccessError
         team = self.team
         content = request.get_form_var("pull_request_comment", "").decode("utf-8")
         self.comment.update(content)
         comment = IssueComment.get(self.comment.id)
         author = user
         target = team
         return dict(r=0, html=st("/widgets/issue/issue_comment.html", **locals()))
예제 #15
0
    def test_issue_stat(self):
        issue_rs = get_all_issue()
        store.execute("delete from issues where id < 20")
        assert len(issue_rs) == 0
        issue_open_count = len(filter(lambda x: x[1] is None, issue_rs))
        assert issue_open_count == 0
        assert len(issue_rs) - issue_open_count == 0

        i1 = Issue.add('test1', 'test des1', 'testuser1', 'assignee')
        issue_rs = get_all_issue()
        assert len(issue_rs) == 1
        issue_open_count = len(filter(lambda x: x[1] is None, issue_rs))
        assert issue_open_count == 1
        assert len(issue_rs) - issue_open_count == 0

        i2 = Issue.add('test2', 'test des1', 'testuser1', 'assignee')
        i3 = Issue.add('test3', 'test des1', 'testuser2', 'assignee')
        issue_rs = get_all_issue()
        assert len(issue_rs) == 3
        issue_open_count = len(filter(lambda x: x[1] is None, issue_rs))
        assert issue_open_count == 3
        assert len(issue_rs) - issue_open_count == 0

        i1.close('testuser1')
        issue_rs = get_all_issue()
        assert len(issue_rs) == 3
        issue_open_count = len(filter(lambda x: x[1] is None, issue_rs))
        assert issue_open_count == 2
        assert len(issue_rs) - issue_open_count == 1

        issue_comment_count = get_issue_comment_count()
        assert issue_comment_count == 0
        IssueComment.add(i2.id, 'content', 'test')
        IssueComment.add(i3.id, 'content', 'test1')
        issue_comment_count = get_issue_comment_count()
        assert issue_comment_count == 2
예제 #16
0
파일: issue.py 프로젝트: 000fan000/code
 def edit(self, request):
     if request.method == 'POST':
         user = request.user
         current_user = request.user
         if self.comment.author_id != user.username:
             raise AccessError
         project = self.project
         content = request.get_form_var(
             'pull_request_comment', '').decode('utf-8')
         self.comment.update(content)
         comment = IssueComment.get(self.comment.id)
         author = user
         target = project
         return dict(
             r=0, html=st('/widgets/issue/issue_comment.html', **locals()))
예제 #17
0
파일: issue.py 프로젝트: jackfrued/code-1
 def edit(self, request):
     if request.method == 'POST':
         user = request.user
         current_user = request.user
         if self.comment.author_id != user.username:
             raise AccessError
         project = self.project
         content = request.get_form_var('pull_request_comment',
                                        '').decode('utf-8')
         self.comment.update(content)
         comment = IssueComment.get(self.comment.id)
         author = user
         target = project
         return dict(r=0,
                     html=st('/widgets/issue/issue_comment.html',
                             **locals()))
예제 #18
0
파일: issue.py 프로젝트: leeccong/code
 def add_comment(self, content, user):
     res = IssueComment.add(self.issue_id, content, user)
     self.update_rank_score()
     return res
예제 #19
0
 def comment_count(self):
     return IssueComment.count_by_issue_id(self.issue_id)
예제 #20
0
 def add_comment(self, content, user):
     res = IssueComment.add(self.issue_id, content, user)
     self.update_rank_score()
     return res
예제 #21
0
파일: issue.py 프로젝트: leeccong/code
 def comments(self):
     return IssueComment.gets_by_issue_id(self.issue_id)
예제 #22
0
파일: issue.py 프로젝트: leeccong/code
 def comment_count(self):
     return IssueComment.count_by_issue_id(self.issue_id)
예제 #23
0
 def comments(self):
     return IssueComment.gets_by_issue_id(self.issue_id)