mybot/mock/client.py

109 lines
3.2 KiB
Python

# -*- coding: utf-8 -*-
# @Time : 2023/4/4 19:57
# @Author : Flora.Chen
# @File : client.py.py
# @Software: PyCharm
# @Desc: 模拟客户端像服务器发送请求
import requests
req_data = {
"ref": "refs/heads/master",
"before": "6c22220fabcf749fdcf4b31b79d5195ff0acb751ef82",
"after": "29f3333339413d42affe9f31e910782b24bb73aaec1540",
"commits": [
{
"id": "a96b8a2222247f9c1cb8882a966cbae239e09c8abc4b0",
"message": "xixixha222hahah",
"author": {
"name": "floraachy",
"email": "flower@qq.com",
"username": ""
},
"timestamp": "2023-04-07T17:28:28+08:00"
},
{
"id": "b1122222f9c1cb8882a966cbae239e09c8abc4b0",
"message": "bbaba22222babab1",
"author": {
"name": "flora",
"email": "flower@gitlink.com",
"username": ""
},
"timestamp": "2023-04-07T17:28:28+08:00"
},
],
"repository": {
"full_name": "floraachy/bot",
}
}
req_data2 = {
"ref": "refs/heads/gitlink",
"before": "22222222222bcf749fdcf4b31b79d5195ff0acb751ef82",
"after": "333333333333333333affe9f31e910782b24bb73aaec1540",
"commits": [
{
"id": "444444444444444441c1cb8882a966cbae239e09c8abc4b0",
"message": "xttttt--sjsjjsjs",
"author": {
"name": "floraachy",
"email": "flower@qq.com",
"username": ""
},
"timestamp": "2023-04-07T17:28:28+08:00"
},
{
"id": "b222222222229c1cb8882a966cbae239e09c8abc4b0",
"message": "test-0099999",
"author": {
"name": "flora",
"email": "flower@gitlink.com",
"username": ""
},
"timestamp": "2023-04-07T17:28:28+08:00"
},
],
"repository": {
"full_name": "floraachy/bot",
}
}
req_data3 = {
"ref": "refs/heads/gitlink",
"before": "5555555555554b31b79d5195ff0acb751ef82",
"after": "66666666666666affe9f31e910782b24bb73aaec1540",
"commits": [
{
"id": "77777777777711111c1cb8882a966cbae239e09c8abc4b0",
"message": "mybot--sjsjjsjs",
"author": {
"name": "floraachy",
"email": "flower@qq.com",
"username": ""
},
"timestamp": "2023-04-07T17:28:28+08:00"
},
{
"id": "88888888888c1cb8882a966cbae239e09c8abc4b0",
"message": "mybot-0099999",
"author": {
"name": "flora",
"email": "flower@gitlink.com",
"username": ""
},
"timestamp": "2023-04-07T17:28:28+08:00"
},
],
"repository": {
"full_name": "floraachy/mybot",
}
}
res = requests.post("http://127.0.0.1:8070/mybot/?installer_id=85589", json=req_data)
res2 = requests.post("http://127.0.0.1:8070/mybot/?installer_id=85589", json=req_data2)
res3 = requests.post("http://127.0.0.1:8070/mybot/?installer_id=85500", json=req_data3)
print(res.status_code)
print(res.text)
# print(res.json())