Пример #1
0
 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()
Пример #2
0
 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()
Пример #3
0
 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()
Пример #4
0
 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()
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 def test_refresh_token_refreshing_no_error(self,
                                            mock_request_patch):
     client = aiClient.AIClient("what", "", "")
     client._time = -3000
     client.CheckIfRefresh()
Пример #8
0
 def test_get_token_no_error(self,
                             mock_request_post):
     client = aiClient.AIClient("what", "", "")
     client.GetToken()
     mock_request_post.assert_called()
Пример #9
0
 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()