示例#1
0
  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)
示例#2
0
    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)
示例#3
0
def _ValidatePatch(patch_data):
    if patch_data:
        patch_details = patch.FromDict(patch_data)
        return patch_details.server, patch_details.change
    return None, None
示例#4
0
 def testFromDictBadUrl(self):
     with self.assertRaises(ValueError):
         patch.FromDict('https://codereview.com/not/a/codereview/url')
示例#5
0
 def testFromDictGerritWithRevision(self):
     p = patch.FromDict('https://codereview.com/c/repo/+/658277/4')
     self.assertEqual(p, Patch('other revision'))
示例#6
0
 def testFromDictGerrit(self):
     p = patch.FromDict('https://codereview.com/c/repo/+/658277')
     self.assertEqual(p, Patch('current revision'))
示例#7
0
 def testFromDictBadUrl(self):
   with self.assertRaises(ValueError):
     patch.FromDict('https://example.com/not/a/gerrit/url')