def testFromDictGerrit(self, get_change): get_change.return_value = _GERRIT_CHANGE_INFO p = patch.FromDict('https://example.com/c/repo/+/658277') expected = patch.GerritPatch( 'https://example.com', 'repo~branch~id', 'current revision') self.assertEqual(p, expected)
def FromDict(cls, data): commits = tuple( commit_module.Commit.FromDict(commit) for commit in data['commits']) if 'patch' in data: patch = patch_module.FromDict(data['patch']) else: patch = None return cls(commits, patch=patch)
def _ValidatePatch(patch_data): if patch_data: patch_details = patch.FromDict(patch_data) return patch_details.server, patch_details.change return None, None
def testFromDictBadUrl(self): with self.assertRaises(ValueError): patch.FromDict('https://codereview.com/not/a/codereview/url')
def testFromDictGerritWithRevision(self): p = patch.FromDict('https://codereview.com/c/repo/+/658277/4') self.assertEqual(p, Patch('other revision'))
def testFromDictGerrit(self): p = patch.FromDict('https://codereview.com/c/repo/+/658277') self.assertEqual(p, Patch('current revision'))
def testFromDictBadUrl(self): with self.assertRaises(ValueError): patch.FromDict('https://example.com/not/a/gerrit/url')