Beispiel #1
0
    def test_get_change(self, mock_get, mock_get_netrc_auth):
        mock_get_netrc_auth.return_value = ('user', 'password')
        get = mock.Mock()
        get.status_code = 200
        get.content = (
            ')]}\''
            '{"name": "gerritproject", '
            '"parent": "All-Projects", '
            '"description": "My gerrit project", '
            '"state": "ACTIVE"}').encode('utf-8')
        mock_get.return_value = get

        reference = Gerrit(url='http://domain.com')
        change = reference.get_change('gerritproject', 'change id')
        self.assertIsInstance(change, Change)
        mock_get.assert_called_with(
            auth=mock.ANY,
            headers=mock.ANY,
            json=mock.ANY,
            url='http://domain.com/a/changes/gerritproject%7Emaster%7Echange%20id/'
        )
Beispiel #2
0
    def test_get_change(self, mock_get, mock_get_netrc_auth):
        mock_get_netrc_auth.return_value = ('user', 'password')
        get = mock.Mock()
        get.status_code = 200
        get.content = (')]}\''
                       '{"name": "gerritproject", '
                       '"parent": "All-Projects", '
                       '"description": "My gerrit project", '
                       '"state": "ACTIVE"}').encode('utf-8')
        mock_get.return_value = get

        reference = Gerrit(url='http://domain.com')
        change = reference.get_change('gerritproject', 'change id')
        self.assertIsInstance(change, Change)
        mock_get.assert_called_with(
            auth=mock.ANY,
            headers=mock.ANY,
            json=mock.ANY,
            url=
            'http://domain.com/a/changes/gerritproject%7Emaster%7Echange%20id/'
        )
Beispiel #3
0
    def test_get_change(self):
        """
        Test that a change can be fetched
        """
        self.get.content = self.build_response({
            "name": self.PROJECT,
            "parent": self.PARENT,
            "description": self.DESCRIPTION,
            "state": self.STATE,
        })

        reference = Gerrit(url=self.URL)
        change = reference.get_change(self.PROJECT, self.CHANGE_ID)
        self.assertIsInstance(change, Change)
        self.mock_get.assert_called_with(
            auth=mock.ANY,
            headers=mock.ANY,
            json=mock.ANY,
            url='{}/a/changes/{}%7E{}%7E{}/'.format(
                self.URL,
                self.PROJECT,
                self.BRANCH,
                self.CHANGE_ID,
            ))