Example #1
0
    def test_get_change(self):
        req_path = 'changes/%s?o=ALL_REVISIONS' % CHANGE_ID
        change_reponse = {
            'id': CHANGE_ID,
            'project': 'project',
            'branch': 'master',
            'hashtags': [],
            'change_id': SHORT_CHANGE_ID,
            'subject': 'My change',
            'status': 'NEW',
            'created': '2014-10-17 18:24:39.193000000',
            'updated': '2014-10-17 20:44:48.338000000',
            'mergeable': True,
            'insertions': 10,
            'deletions': 11,
            '_sortkey': '0030833c0002bff9',
            '_number': 180217,
            'owner': {
                'name': 'John Doe'
            },
            'current_revision': REVISION,
            'revisions': {
                REVISION: {
                    '_number': 1,
                    'fetch': {
                        'http': {
                            'url':
                            'https://chromium.googlesource.com/html-office',
                            'ref': 'refs/changes/80/123/1'
                        }
                    }
                }
            }
        }
        client = GerritClient('chromium-review.googlesource.com')
        client._fetch = Mock(return_value=change_reponse)
        change = client.get_change(CHANGE_ID)
        client._fetch.assert_called_once_with(req_path)
        self.assertIsNotNone(change)
        self.assertEqual(change.change_id, SHORT_CHANGE_ID)
        self.assertEqual(change.branch, 'master')
        self.assertEqual(change.project, 'project')
        self.assertEqual(change.owner.name, 'John Doe')
        self.assertEqual(change.current_revision, REVISION)

        # smoke test for branch coverage
        change = client.get_change(CHANGE_ID,
                                   include_all_revisions=False,
                                   include_owner_details=True)
Example #2
0
  def test_get_change(self):
    req_path = 'changes/%s?o=ALL_REVISIONS' % CHANGE_ID
    change_reponse = {
        'id': CHANGE_ID,
        'project': 'project',
        'branch': 'master',
        'hashtags': [],
        'change_id': SHORT_CHANGE_ID,
        'subject': 'My change',
        'status': 'NEW',
        'created': '2014-10-17 18:24:39.193000000',
        'updated': '2014-10-17 20:44:48.338000000',
        'mergeable': True,
        'insertions': 10,
        'deletions': 11,
        '_sortkey': '0030833c0002bff9',
        '_number': 180217,
        'owner': {
            'name': 'John Doe'
        },
        'current_revision': REVISION,
        'revisions': {
            REVISION: {
                '_number': 1,
                'fetch': {
                  'http': {
                      'url': 'https://chromium.googlesource.com/html-office',
                      'ref': 'refs/changes/80/123/1'
                  }
                }
            }
        }
    }
    client = GerritClient('chromium-review.googlesource.com')
    client._fetch = Mock(return_value=change_reponse)
    change = client.get_change(CHANGE_ID)
    client._fetch.assert_called_once_with(req_path)
    self.assertIsNotNone(change)
    self.assertEqual(change.change_id, SHORT_CHANGE_ID)
    self.assertEqual(change.branch, 'master')
    self.assertEqual(change.project, 'project')
    self.assertEqual(change.owner.name, 'John Doe')
    self.assertEqual(change.current_revision, REVISION)

    # smoke test for branch coverage
    change = client.get_change(CHANGE_ID, include_all_revisions=False,
                               include_owner_details=True)
Example #3
0
 def test_get_nonexistent_change(self):
     client = GerritClient('chromium-review.googlesource.com')
     change = client.get_change(CHANGE_ID)
     self.assertIsNone(change)
Example #4
0
 def test_get_nonexistent_change(self):
   client = GerritClient('chromium-review.googlesource.com')
   change = client.get_change(CHANGE_ID)
   self.assertIsNone(change)