def test_refresh_token_connection_error(self): with self.assertRaises(ConnectionError) as cm: capturedOutput = io.StringIO() # setup an io sys.stdout = capturedOutput # redirect stdout client = aiClient.AIClient("what", "", "") client._time = -3000 client.CheckIfRefresh()
def test_optimizer_optimize_error_post(self, mock_check_if_refresh): with self.assertRaises(IOError) as cm: capturedOutput = io.StringIO() # setup an io sys.stdout = capturedOutput # redirect stdout client = aiClient.AIClient(aiClient.APP_KEY, aiClient.APP_ID, aiClient.SEC) client._token = "what" client.Optimize()
def test_optimize_no_token(self, mock_get_token): with self.assertRaises(OSError) as cm: capturedOutput = io.StringIO() # setup an io sys.stdout = capturedOutput # redirect stdout client = aiClient.AIClient("what", "", "") client.Optimize() mock_get_token.assert_called()
def test_optimize_optimize_error_patch(self, mock_check_if_refresh, req_post): with self.assertRaises(IOError) as cm: capturedOutput = io.StringIO() # setup an io sys.stdout = capturedOutput # redirect stdout client = aiClient.AIClient("what", "", "") client._token = "what" client.Optimize() req_post.assert_called()
def test_push_symbol_res_connect_error(self): sym = jsClass.SymbolUpdate("test") sym.setLang("test2") sym.setPath("test") sym.setType("test") proto = jsClass.SymbolPrototype("test") proto.setPrototype("test") proto.setDescription("") param = jsClass.SymbolParam("test") param.setPath("") param.setDescription("") param.setPrototype("test") proto.appendParameters(param) proto.appendParameters(param) sym.appendPrototypes(proto) sym.appendPrototypes(proto) sym.appendSymbols("test") with self.assertRaises(OSError) as cm: capturedOutput = io.StringIO() # setup an io sys.stdout = capturedOutput # redirect stdout client = aiClient.AIClient(aiClient.APP_KEY, aiClient.APP_ID, aiClient.SEC) client.GetToken() client.PushSymbol(sym)
def test_push_symbol_error(self, mock_get_token): sym = jsClass.SymbolUpdate("test") sym.setLang("test2") sym.setPath("test") sym.setType("test") proto = jsClass.SymbolPrototype("test") proto.setPrototype("test") proto.setDescription("") param = jsClass.SymbolParam("test") param.setPath("") param.setDescription("") param.setPrototype("test") proto.appendParameters(param) proto.appendParameters(param) sym.appendPrototypes(proto) sym.appendPrototypes(proto) sym.appendSymbols("test") with self.assertRaises(OSError) as cm: capturedOutput = io.StringIO() # setup an io sys.stdout = capturedOutput # redirect stdout client = aiClient.AIClient("what", "", "") client.PushSymbol(sym)
def test_refresh_token_refreshing_no_error(self, mock_request_patch): client = aiClient.AIClient("what", "", "") client._time = -3000 client.CheckIfRefresh()
def test_get_token_no_error(self, mock_request_post): client = aiClient.AIClient("what", "", "") client.GetToken() mock_request_post.assert_called()
def test_get_token_connection_error(self): with self.assertRaises(ConnectionError) as cm: capturedOutput = io.StringIO() # setup an io sys.stdout = capturedOutput # redirect stdout client = aiClient.AIClient("what", "", "") client.GetToken()