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)
def setUp(self): super(TestPublish, self).setUp() self.user = User('*****@*****.**') self.login('*****@*****.**') self.issue = models.Issue(subject='test') self.issue.local_base = False self.issue.put() self.ps = models.PatchSet(parent=self.issue, issue=self.issue) self.ps.data = load_file('ps1.diff') self.ps.save() self.patches = engine.ParsePatchSet(self.ps) db.put(self.patches)
def create_issue(self, date, reviewers=None, cc=None): """Creates an issue by self.author with self.reviewer1 as a reviewer.""" date = datetime.datetime.strptime('2011-03-' + date, '%Y-%m-%d %H:%M') issue = models.Issue( subject='test', owner=self.author.user, reviewers=[r.email for r in reviewers or [self.reviewer1]], cc=[db.Email('*****@*****.**')] + [c.email for c in cc or []], created=date, modified=date) issue.put() # Verify that our auto_now hack works. self.assertEqual(issue.key.get().created, date) self.assertEqual(issue.key.get().modified, date) ps = models.PatchSet( parent=issue.key, issue_key=issue.key, created=date, modified=date) ps.data = utils.load_file('ps1.diff') ps.put() patches = engine.ParsePatchSet(ps) ndb.put_multi(patches) return issue