Esempio n. 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)
Esempio n. 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)
Esempio n. 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
Esempio n. 4
0
 def testFromDictBadUrl(self):
     with self.assertRaises(ValueError):
         patch.FromDict('https://codereview.com/not/a/codereview/url')
Esempio n. 5
0
 def testFromDictGerritWithRevision(self):
     p = patch.FromDict('https://codereview.com/c/repo/+/658277/4')
     self.assertEqual(p, Patch('other revision'))
Esempio n. 6
0
 def testFromDictGerrit(self):
     p = patch.FromDict('https://codereview.com/c/repo/+/658277')
     self.assertEqual(p, Patch('current revision'))
Esempio n. 7
0
 def testFromDictBadUrl(self):
   with self.assertRaises(ValueError):
     patch.FromDict('https://example.com/not/a/gerrit/url')