Beispiel #1
0
    def test_gets_by_target_and_ref(self):
        # commit
        self.clear_comments(CommitLineComment, TARGET_ID, FROM_SHA)
        c1 = CommitLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                                   OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                                   20, 30, AUTHOR, CONTENT1)
        c2 = CommitLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                                   OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                                   20, 30, AUTHOR, CONTENT1)
        c3 = CommitLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                                   OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                                   20, 30, AUTHOR, CONTENT1)
        cs = CommitLineComment.gets_by_target_and_ref(TARGET_ID, FROM_SHA)
        assert len(cs) == 3

        self.clear_comments(PullLineComment, TARGET_ID, FROM_SHA)
        # pull
        PullLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                            OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                            20, 30, AUTHOR, CONTENT1)
        PullLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                            OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                            20, 30, AUTHOR, CONTENT1)
        cs = PullLineComment.gets_by_target_and_ref(TARGET_ID, FROM_SHA)
        assert len(cs) == 2
Beispiel #2
0
 def add_codereview(self, from_sha, to_sha, old_path, new_path, from_oid,
                    to_oid, old_linenum, new_linenum, author, content):
     new_path = new_path or old_path
     self.add_participant(author)
     codereview = PullLineComment.add(self.id, from_sha, to_sha, old_path,
                                      new_path, from_oid, to_oid,
                                      old_linenum, new_linenum, author,
                                      content)
     TicketNode.add_codereview(codereview)
     return codereview
Beispiel #3
0
 def add_codereview(self, from_sha, to_sha,
                    old_path, new_path, from_oid, to_oid,
                    old_linenum, new_linenum,
                    author, content):
     new_path = new_path or old_path
     self.add_participant(author)
     codereview = PullLineComment.add(self.id, from_sha, to_sha,
                                      old_path, new_path, from_oid,
                                      to_oid, old_linenum, new_linenum,
                                      author, content)
     TicketNode.add_codereview(codereview)
     return codereview
Beispiel #4
0
    def test_update_comment(self):
        # commit
        c1 = CommitLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                                   OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                                   20, 30, AUTHOR, CONTENT1)
        assert c1.content == CONTENT1
        c1.update(CONTENT2)
        c1 = CommitLineComment.get(c1.id)
        assert c1.content == CONTENT2

        # pull
        c2 = PullLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                                 OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                                 20, 30, AUTHOR, CONTENT2)
        assert c2.content == CONTENT2
        c2.update(CONTENT_ZH)
        c2 = CommitLineComment.get(c2.id)
        assert c2.content == CONTENT_ZH
Beispiel #5
0
    def test_delete_comment(self):
        # commit
        c1 = CommitLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                                   OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                                   20, 30, AUTHOR, CONTENT1)
        cs = CommitLineComment.gets_by_target_and_ref(TARGET_ID, FROM_SHA)
        assert len(cs) == 1
        c1.delete()
        cs = CommitLineComment.gets_by_target_and_ref(TARGET_ID, FROM_SHA)
        assert len(cs) == 0

        # pull
        c2 = PullLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                                 OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                                 20, 30, AUTHOR, CONTENT1)
        cs = PullLineComment.gets_by_target_and_ref(TARGET_ID, FROM_SHA)
        assert len(cs) == 1
        c2.delete()
        cs = PullLineComment.gets_by_target_and_ref(TARGET_ID, FROM_SHA)
        assert len(cs) == 0
Beispiel #6
0
    def test_add_comment(self):
        # commit
        c1 = CommitLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                                   OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                                   20, 30, AUTHOR, CONTENT1)
        assert c1.target_id == TARGET_ID
        assert c1.target_type == LINECOMMENT_TYPE_COMMIT
        assert c1.from_sha == FROM_SHA
        assert c1.to_sha == TO_SHA
        assert c1.old_path == OLD_PATH
        assert c1.new_path == NEW_PATH
        assert c1.from_oid == FROM_OID
        assert c1.to_oid == TO_OID
        assert c1.old_linenum == 20
        assert c1.new_linenum == 30
        assert c1.linenum == (20, 30)
        assert c1.author == AUTHOR
        assert c1.content == CONTENT1
        assert c1.position is None
        assert c1.paths

        # pull
        c2 = PullLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                                 OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                                 20, 30, AUTHOR, CONTENT2)
        assert c2.target_id == TARGET_ID
        assert c2.target_type == LINECOMMENT_TYPE_PULL
        assert c2.from_sha == FROM_SHA
        assert c2.to_sha == TO_SHA
        assert c2.old_path == OLD_PATH
        assert c2.new_path == NEW_PATH
        assert c2.from_oid == FROM_OID
        assert c2.to_oid == TO_OID
        assert c2.old_linenum == 20
        assert c2.new_linenum == 30
        assert c2.linenum == (20, 30)
        assert c2.author == AUTHOR
        assert c2.content == CONTENT2
        assert c2.position is None
        assert c2.paths
Beispiel #7
0
    def test_delete_comment(self):
        # commit
        self.clear_comments(CommitLineComment, TARGET_ID, FROM_SHA)
        c1 = CommitLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                                   OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                                   20, 30, AUTHOR, CONTENT1)
        cs = CommitLineComment.gets_by_target_and_ref(TARGET_ID, FROM_SHA)
        assert len(cs) == 1
        c1.delete()
        cs = CommitLineComment.gets_by_target_and_ref(TARGET_ID, FROM_SHA)
        assert len(cs) == 0

        # pull
        self.clear_comments(PullLineComment, TARGET_ID, FROM_SHA)
        c2 = PullLineComment.add(TARGET_ID, FROM_SHA, TO_SHA,
                                 OLD_PATH, NEW_PATH, FROM_OID, TO_OID,
                                 20, 30, AUTHOR, CONTENT1)
        cs = PullLineComment.gets_by_target_and_ref(TARGET_ID, FROM_SHA)
        assert len(cs) == 1
        c2.delete()
        cs = PullLineComment.gets_by_target_and_ref(TARGET_ID, FROM_SHA)
        assert len(cs) == 0