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
def test_ticket_code_review(self): title = 'test title' desc = 'test desc' author = 'testuser' p1_t1 = Ticket.add(self.proj1.id, title, desc, author) pullreq1 = PullRequest.open(self.proj1_fork, 'master', self.proj1, 'master') pullreq1 = pullreq1.insert(p1_t1.ticket_number) # ticket code review path = '/README.md' #position = 10 from_sha = '454418c61cd7ef1a65818121746b45064a5af5d6' oid = '454418c61cd7ef1a65818121746b45064a5af5d6' codereview = p1_t1.add_codereview(from_sha, '', path, path, oid, oid, LINECOMMENT_INDEX_EMPTY, LINECOMMENT_INDEX_EMPTY, author, 'comment content') assert codereview.ticket_id == p1_t1.id assert codereview.path == path assert codereview.from_sha == from_sha # test update content assert codereview.content == 'comment content' codereview.update('content updated') codereview = PullLineComment.get(codereview.id) assert codereview.content == 'content updated' codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 1 p1_t1.add_codereview(from_sha, '', path, path, oid, oid, LINECOMMENT_INDEX_EMPTY, LINECOMMENT_INDEX_EMPTY, author, 'another comment content') codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 2 # test delete comment codereview.delete() codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 1
def test_ticket_code_review(self): title = 'test title' desc = 'test desc' author = 'testuser' p1_t1 = Ticket.add(self.proj1.id, title, desc, author) pullreq1 = PullRequest.open( self.proj1_fork, 'master', self.proj1, 'master') pullreq1 = pullreq1.insert(p1_t1.ticket_number) # ticket code review path = '/README.md' #position = 10 from_sha = '454418c61cd7ef1a65818121746b45064a5af5d6' oid = '454418c61cd7ef1a65818121746b45064a5af5d6' codereview = p1_t1.add_codereview( from_sha, '', path, path, oid, oid, LINECOMMENT_INDEX_EMPTY, LINECOMMENT_INDEX_EMPTY, author, 'comment content') assert codereview.ticket_id == p1_t1.id assert codereview.path == path assert codereview.from_sha == from_sha #test update content assert codereview.content == 'comment content' codereview.update('content updated') codereview = PullLineComment.get(codereview.id) assert codereview.content == 'content updated' codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 1 p1_t1.add_codereview( from_sha, '', path, path, oid, oid, LINECOMMENT_INDEX_EMPTY, LINECOMMENT_INDEX_EMPTY, author, 'another comment content') codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 2 #test delete comment codereview.delete() codereviews = PullLineComment.gets_by_target_and_ref( p1_t1.id, from_sha) assert len(codereviews) == 1
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
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