ATDDCase.py
3.22 KB
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
# -*- coding: utf-8 -*-
import unittest
import requests
# 多企业选择处理
class ATDDCase(unittest.TestCase):
# 全局变量 -yq环境
global list
# host = "https://yq.vchangyi.com"
#
# uc_host = "http://restapi.99hr.com"
# domain = 'ECF532420A6916AB184EB6409E7FE413'
# mobile = '17321009308'
# psw = '222222'
# jipeihong_uid = '755DE0550A69039F0BA12102F4A4F8E1' # 季培红的UID
# cert = ('1_vchangyi.com_bundle.crt', '2_vchangyi.com.key')
#
# header_json = {"Content-Type": "application/json; charset=utf-8"}
# header_form = {"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"}
# 测试环境
global list
host = "https://yuanquan.vchangyi.com"
uc_host = "http://t-rst.vchangyi.com"
domain = '6F91FA1D7F00000106413BB6F47A9F54' # 企业号“颤抖的小包包”
mobile = '17321009308'
psw = 'test123456'
jipeihong_uid = '6F920BAB7F00000169D1924CB1318A56' # 季培红的UID
cert = ('1_vchangyi.com_bundle.crt', '2_vchangyi.com.key')
header_json = {"Content-Type": "application/json; charset=utf-8"}
header_form = {"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"}
# 全局cookie
session = requests.Session()
def parse_array(self, prop, value_array):
req_params = {}
count = 0
tpl = "{prop}[{count}][{key}]"
for value in value_array:
for key, val in value.items():
req_params[tpl.format_map({
"prop":prop,
"count":count,
"key":key
})] = val
count += 1
return req_params
def tearDown(self):
if self.session is not None:
self.session.close()
# 请求方法定义
def post(self, url, data=None, **kwargs):
assert self.session
assert url
return self.session.post(
url,
data=data,
**kwargs
)
def get(self, url, **kwargs):
assert self.session
assert url
return self.session.get(
self.host + '/' + self.domain + url,
**kwargs
)
def put(self, url, data=None, **kwargs):
assert self.session
assert url
return self.session.put(
self.host + '/' + self.domain + url,
data=data, **kwargs
)
def delete(self, url, **kwargs):
assert self.session
assert url
return self.session.delete(
self.host + '/' + self.domain + url,
**kwargs
)
def patch(self, url, data=None, **kwargs):
assert self.session
assert url
return self.session.patch(
self.host + '/' + self.domain + url,
data=data, **kwargs
)
def head(self, url, **kwargs):
assert self.session
assert url
return self.session.head(
self.host + '/' + self.domain + url,
**kwargs
)
def options(self, url, **kwargs):
assert self.session
assert url
return self.session.options(
self.host + '/' + self.domain + url,
**kwargs
)