def test_create_change(self): """ Test that a change can be created """ reference = Gerrit(url=self.URL) change = reference.create_change(self.PROJECT, 'change status') self.assertIsInstance(change, Change) self.mock_post.assert_called_with(auth=mock.ANY, headers=mock.ANY, json=mock.ANY, url='{}/a/changes/'.format(self.URL))
def test_create_change(self, mock_get, mock_post, mock_get_netrc_auth): mock_get_netrc_auth.return_value = ('user', 'password') post = mock.Mock() post.status_code = 201 post.content = ')]}\'{"change_id": "I01440b5fd46a67ee38c9ef2c22eb145b8547cbb2"}'.encode( 'utf-8') mock_post.return_value = post get = mock.Mock() get.status_code = 200 get.content = ')]}\'{}'.encode('utf-8') mock_get.return_value = get reference = Gerrit(url='http://domain.com') change = reference.create_change('gerritproject', 'change status') self.assertIsInstance(change, Change) mock_post.assert_called_with(auth=mock.ANY, headers=mock.ANY, json=mock.ANY, url='http://domain.com/a/changes/')
def test_create_change(self, mock_get, mock_post, mock_get_netrc_auth): mock_get_netrc_auth.return_value = ('user', 'password') post = mock.Mock() post.status_code = 201 post.content = ')]}\'{"change_id": "I01440b5fd46a67ee38c9ef2c22eb145b8547cbb2"}'.encode('utf-8') mock_post.return_value = post get = mock.Mock() get.status_code = 200 get.content = ')]}\'{}'.encode('utf-8') mock_get.return_value = get reference = Gerrit(url='http://domain.com') change = reference.create_change('gerritproject', 'change status') self.assertIsInstance(change, Change) mock_post.assert_called_with( auth=mock.ANY, headers=mock.ANY, json=mock.ANY, url='http://domain.com/a/changes/' )