Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 2 Fork 1

APIJSON/UnitAuto

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (11)
Tags (14)
master
dependabot/maven/UnitAuto-SpringBoot-SDK/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java-Demo/mysql-mysql-connector-java-8.0.28
dependabot/maven/UnitAuto-Jar/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java-Demo/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java-Demo/mysql-mysql-connector-java-8.0.16
dependabot/maven/UnitAuto-Java-SpringBoot/mysql-mysql-connector-java-8.0.16
dependabot/maven/Demo/UnitAuto-Java-SpringBoot/mysql-mysql-connector-java-8.0.16
dependabot/maven/UnitAutoBoot/mysql-mysql-connector-java-8.0.16
dependabot/maven/UnitAuto-Backend/UnitAutoBoot/mysql-mysql-connector-java-8.0.16
3.0.0
2.9.5
2.9.0
2.8.1
2.7.3
2.7.2
2.6.4
2.6.3
2.6.0
2.5.0
2.4.0
2.0.0
1.0.3
1.0.0
master
Branches (11)
Tags (14)
master
dependabot/maven/UnitAuto-SpringBoot-SDK/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java-Demo/mysql-mysql-connector-java-8.0.28
dependabot/maven/UnitAuto-Jar/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java-Demo/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java-Demo/mysql-mysql-connector-java-8.0.16
dependabot/maven/UnitAuto-Java-SpringBoot/mysql-mysql-connector-java-8.0.16
dependabot/maven/Demo/UnitAuto-Java-SpringBoot/mysql-mysql-connector-java-8.0.16
dependabot/maven/UnitAutoBoot/mysql-mysql-connector-java-8.0.16
dependabot/maven/UnitAuto-Backend/UnitAutoBoot/mysql-mysql-connector-java-8.0.16
3.0.0
2.9.5
2.9.0
2.8.1
2.7.3
2.7.2
2.6.4
2.6.3
2.6.0
2.5.0
2.4.0
2.0.0
1.0.3
1.0.0
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (11)
Tags (14)
master
dependabot/maven/UnitAuto-SpringBoot-SDK/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java-Demo/mysql-mysql-connector-java-8.0.28
dependabot/maven/UnitAuto-Jar/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java-Demo/com.alibaba-fastjson-1.2.83
dependabot/maven/UnitAuto-Java-Demo/mysql-mysql-connector-java-8.0.16
dependabot/maven/UnitAuto-Java-SpringBoot/mysql-mysql-connector-java-8.0.16
dependabot/maven/Demo/UnitAuto-Java-SpringBoot/mysql-mysql-connector-java-8.0.16
dependabot/maven/UnitAutoBoot/mysql-mysql-connector-java-8.0.16
dependabot/maven/UnitAuto-Backend/UnitAutoBoot/mysql-mysql-connector-java-8.0.16
3.0.0
2.9.5
2.9.0
2.8.1
2.7.3
2.7.2
2.6.4
2.6.3
2.6.0
2.5.0
2.4.0
2.0.0
1.0.3
1.0.0
server.py 7.10 KB
Copy Edit Raw Blame History
TommyLemon authored 2023年08月07日 14:06 +08:00 . 更新 Go 版 和 Python 版源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
# encoding=utf-8
# MIT License
#
# Copyright (c) 2023 TommyLemon
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import json
from unitauto import methodutil
from unitauto.methodutil import null, true, false, to_json_str, list_method, invoke_method, KEY_PACKAGE, KEY_CLASS, \
KEY_CONSTRUCTOR, KEY_CLASS_ARGS, KEY_THIS, KEY_METHOD, KEY_METHOD_ARGS, KEY_TYPE, KEY_VALUE, KEY_RETURN, KEY_KEY, \
KEY_ASYNC, KEY_CALLBACK
from http.server import HTTPServer, BaseHTTPRequestHandler
CHARSET = 'uft-8'
HOST = ('localhost', 8083)
RESPONSE_CODE_SUCCESS = 200
KEY_CONTENT_TYPE = 'Content-Type'
KEY_CONTENT_LENGTH = 'Content-Length'
CONTENT_TYPE = 'application/json; charset=UTF-8'
class Request(BaseHTTPRequestHandler):
timeout = 5
server_version = "Apache"
def send_headers(self, origin, method='POST'):
self.send_header(KEY_CONTENT_TYPE, CONTENT_TYPE)
self.send_header('Access-Control-Allow-Origin', origin)
self.send_header('Access-Control-Allow-Credentials', 'true')
self.send_header('Access-Control-Allow-Headers', 'Content-Type,content-type')
self.send_header('Access-Control-Allow-Methods', 'POST,GET,OPTIONS')
self.send_header('Access-Control-Request-Method', method)
self.end_headers()
def do_OPTIONS(self):
self.do_POST()
def do_POST(self):
method = self.command
client_address = self.client_address
host = 'http://' + client_address[0] + ':' + str(client_address[1])
path = self.path
print(method + ' ' + host + path)
if path not in ['/method/list', '/method/invoke']:
raise Exception('only support /method/list, /method/invoke')
origin = self.headers.get('origin') or self.headers.get('Origin') or 'http://apijson.cn'
if method == 'OPTIONS':
self.send_response(RESPONSE_CODE_SUCCESS)
self.send_headers(origin, method)
# self.wfile.write('ok'.encode())
return
bs = self.rfile.read(int(self.headers[KEY_CONTENT_LENGTH]))
req = bs.decode() # bs.decode(CHARSET)
# req = urllib.unquote(bs).decode(CHARSET, 'ignore')
done = [false]
wfile = self.wfile
def callback(res):
res_str = to_json_str(res)
res_byte = res_str.encode()
self.send_response(RESPONSE_CODE_SUCCESS)
self.send_headers(origin, method)
if done[0] or wfile is None or wfile.closed:
return
wfile.write(res_byte)
done[0] = true
try:
wfile.close()
except BaseException as e:
# print(e)
pass
# cause error 'unresolved reference' wfile = null
if path == '/method/list':
rsp = list_method(req)
callback(rsp)
else:
invoke_method(req, callback)
while true:
if done[0]:
break
def start(host=HOST):
server = HTTPServer(host, Request)
print("Starting server, listen at: %s:%s" % host)
server.serve_forever()
def test():
rsp0 = invoke_method({
KEY_PACKAGE: 'unitauto.test',
KEY_METHOD: 'test'
})
print('\nunitauto.test.test() = \n' + to_json_str(rsp0))
rsp1 = invoke_method({
KEY_PACKAGE: 'unitauto.test',
KEY_CLASS: 'testutil',
KEY_METHOD: 'minus',
KEY_METHOD_ARGS: [
{
KEY_TYPE: 'int',
KEY_VALUE: 2
},
{
KEY_TYPE: 'int',
KEY_VALUE: 3
}
]
})
print('\nunitauto.test.testutil.minus(2, 3) = \n' + to_json_str(rsp1))
rsp2 = invoke_method({
KEY_PACKAGE: 'unitauto.test',
KEY_CLASS: 'testutil$Test',
KEY_CLASS_ARGS: [
1,
0,
'UnitAuto'
],
KEY_METHOD: 'get_id'
})
print('\nunitauto.test.testutil.Test.get_id() = \n' + to_json_str(rsp2))
rsp3 = invoke_method({
KEY_PACKAGE: 'unitauto.test',
KEY_CLASS: 'testutil$Test',
KEY_CONSTRUCTOR: 'get_test_instance',
KEY_CLASS_ARGS: [
2,
1,
'UnitAuto@Python'
],
KEY_METHOD: 'get_name'
})
print('\nunitauto.test.testutil.Test.get_name() = \n' + to_json_str(rsp3))
rsp4 = invoke_method({
KEY_PACKAGE: 'unitauto.test',
KEY_CLASS: 'testutil$Test',
KEY_THIS: {
KEY_TYPE: 'unitauto.test.testutil$Test',
KEY_VALUE: {
'id': 3,
'sex': 1,
'name': 'UnitAuto'
}
},
KEY_METHOD: 'get_sex_str'
})
print('\nunitauto.test.testutil.Test.get_sex_str() = \n' + to_json_str(rsp4))
rsp5 = invoke_method({
KEY_ASYNC: true,
KEY_PACKAGE: 'unitauto.test',
KEY_CLASS: 'testutil',
KEY_METHOD: 'async_test',
KEY_METHOD_ARGS: [
{
KEY_TYPE: 'int',
KEY_VALUE: 2
},
{
KEY_TYPE: 'int',
KEY_VALUE: 5
}
]
})
print('\nunitauto.test.testutil.async_test(2, 5) = \n' + to_json_str(rsp5))
def callback(rsp):
print('unitauto.test.testutil.compute_async(2, 5, callback) = \n' + to_json_str(rsp))
rsp6 = invoke_method({
KEY_PACKAGE: 'unitauto.test',
KEY_CLASS: 'testutil',
KEY_METHOD: 'compute_async',
KEY_METHOD_ARGS: [
{
# KEY_KEY: 'a',
KEY_TYPE: 'int',
KEY_VALUE: 2
},
{
# KEY_KEY: 'b',
KEY_TYPE: 'int',
KEY_VALUE: 5
},
{
KEY_KEY: 'callback',
KEY_TYPE: 'def(a,b)',
KEY_VALUE: {
KEY_TYPE: 'int',
KEY_RETURN: 'a - b',
KEY_CALLBACK: true
}
}
]
}, callback)
print('\nunitauto.test.testutil.compute_async(2, 5, callback) = \n' + to_json_str(rsp6))
if __name__ == '__main__':
test()
start()
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

机器学习单元测试平台,零代码、全方位、自动化 测试 方法/函数 的正确性和可用性。本仓库为副本,请给原仓库右上角点亮 ⭐️ Star
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/APIJSON/UnitAuto.git
git@gitee.com:APIJSON/UnitAuto.git
APIJSON
UnitAuto
UnitAuto
master
Going to Help Center

Search

Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /