@@ -0,0 +1,2380 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0A%0A# The MIT License%0A#%0A# Copyright 2018 David Pursehouse. All rights reserved.%0A#%0A# Permission is hereby granted, free of charge, to any person obtaining a copy%0A# of this software and associated documentation files (the %22Software%22), to deal%0A# in the Software without restriction, including without limitation the rights%0A# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A# copies of the Software, and to permit persons to whom the Software is%0A# furnished to do so, subject to the following conditions:%0A#%0A# The above copyright notice and this permission notice shall be included in%0A# all copies or substantial portions of the Software.%0A#%0A# THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN%0A# THE SOFTWARE.%0A%0A%22%22%22Live server tests.%22%22%22%0A%0Aimport unittest%0Afrom pygerrit2.rest import GerritRestAPI, GerritReview%0Afrom pygerrit2.rest.auth import HTTPBasicAuthFromNetrc%0A%0Aurl = %22http://localhost:8080%22%0Aauth = HTTPBasicAuthFromNetrc(url)%0Aapi = GerritRestAPI(url=url, auth=auth)%0A%0A%0Aclass TestLiveServer(unittest.TestCase):%0A    %22%22%22Test that GerritRestAPI behaves properly against a live server.%22%22%22%0A%0A    def test_live_server(self):%0A        %22%22%22Run the tests.%22%22%22%0A        # Post with content as dict%0A        changeinput = %7B%22project%22: %22test-project%22,%0A                       %22subject%22: %22subject%22,%0A                       %22branch%22: %22master%22,%0A                       %22topic%22: %22topic%22%7D%0A        change = api.post(%22/changes/%22, json=changeinput)%0A        id = change%5B%22id%22%5D%0A%0A        # Get%0A        api.get(%22/changes/%22 + id)%0A%0A        # Put with content as string%0A        api.put(%22/changes/%22 + id + %22/edit/foo%22, data=%22content%22)%0A%0A        # Put with no content%0A        api.put(%22/changes/%22 + id + %22/edit/foo%22)%0A%0A        # Review by API%0A        rev = GerritReview()%0A        rev.set_message(%22Review from live test%22)%0A        rev.add_labels(%7B%22Code-Review%22: 1%7D)%0A        api.review(id, %22current%22, rev)%0A%0A%0Aif __name__ == '__main__':%0A    unittest.main()%0A

Add basic tests running against a live Gerrit server