def test_empty_patch(self): issue = models.Issue(subject="test with 0 lines") issue.local_base = False issue.put() added, removed = views._get_modified_counts(issue) self.assertEqual(0, added) self.assertEqual(0, removed)
def test_both_patch(self): issue = models.Issue(subject="test with changes") issue.local_base = False issue.put() ps = models.PatchSet(parent=issue.key, issue_key=issue.key) ps.data = self.makePatch(5, 7) ps.put() patches = engine.ParsePatchSet(ps) ndb.put_multi(patches) added, removed = views._get_modified_counts(issue) self.assertEqual(5, added) self.assertEqual(7, removed)
def test_remove_patch(self): issue = models.Issue(subject="test with 1 line removed") issue.local_base = False issue.put() ps = models.PatchSet(parent=issue, issue=issue) ps.data = self.makePatch(0, 1) ps.save() patches = engine.ParsePatchSet(ps) db.put(patches) added, removed = views._get_modified_counts(issue) self.assertEqual(0, added) self.assertEqual(1, removed)