def test_server_version_json(self): '''test_server_version_json tests expected versions for json support.''' sc = ServerCapabilities("foo", {"version": (2, 4, 0)}) sc.version = (2, 3, 99) self.assertRaises(api.ShotgunError, sc._ensure_json_supported) self.assertRaises(api.ShotgunError, ServerCapabilities, "foo", {"version": (2, 2, 0)}) sc.version = (0, 0, 0) self.assertRaises(api.ShotgunError, sc._ensure_json_supported) sc.version = (2, 4, 0) sc._ensure_json_supported() sc.version = (2, 5, 0) sc._ensure_json_supported()
def test_server_version_json(self): '''test_server_version_json tests expected versions for json support.''' sc = ServerCapabilities("foo", {"version" : (2,4,0)}) sc.version = (2,3,99) self.assertRaises(api.ShotgunError, sc._ensure_json_supported) self.assertRaises(api.ShotgunError, ServerCapabilities, "foo", {"version" : (2,2,0)}) sc.version = (0,0,0) self.assertRaises(api.ShotgunError, sc._ensure_json_supported) sc.version = (2,4,0) sc._ensure_json_supported() sc.version = (2,5,0) sc._ensure_json_supported()
def _setup_mock(self): """Setup mocking on the ShotgunClient to stop it calling a live server """ #Replace the function used to make the final call to the server #eaiser than mocking the http connection + response self.sg._http_request = mock.Mock(spec=api.Shotgun._http_request, return_value=((200, "OK"), {}, None)) #also replace the function that is called to get the http connection #to avoid calling the server. OK to return a mock as we will not use #it self.mock_conn = mock.Mock(spec=api.lib.httplib2.Http) #The Http objects connection property is a dict of connections #it is holding self.mock_conn.connections = dict() self.sg._connection = self.mock_conn self.sg._get_connection = mock.Mock(return_value=self.mock_conn) #create the server caps directly to say we have the correct version self.sg._server_caps = ServerCapabilities(self.sg.config.server, {"version" : [2,4,0]})