forked from ShilongLee/Crawler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjd.py
70 lines (63 loc) · 2.22 KB
/
jd.py
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
import requests
from cookie import HOST, JD_COOKIE
import unittest
class TestModule(unittest.TestCase):
# 添加账户接口
def test_add_account(self):
data = {
"id": "test",
"cookie": JD_COOKIE
}
response = requests.post(f'{HOST}/jd/add_account', json=data)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()['code'], 0)
# 账户列表接口
def test_account_list(self):
# 添加账户
data = {
"id": "test",
"cookie": JD_COOKIE
}
response = requests.post(f'{HOST}/jd/add_account', json=data)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()['code'], 0)
# 获取账户列表
response = requests.get(f'{HOST}/jd/account_list')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()['code'], 0)
self.assertGreater(len(response.json()['data']), 0)
# 过期账户接口
def test_expire_account(self):
# 添加账户
data = {
"id": "test",
"cookie": JD_COOKIE
}
response = requests.post(f'{HOST}/jd/add_account', json=data)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()['code'], 0)
# 过期账户
data = {
"id": "test",
}
response = requests.post(f'{HOST}/jd/expire_account', json=data)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()['code'], 0)
# 搜索接口
def test_search(self):
# 添加账户
data = {
"id": "test",
"cookie": JD_COOKIE
}
response = requests.post(f'{HOST}/jd/add_account', json=data)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()['code'], 0)
# 搜索
param = {
"keyword" : "白丝"
}
response = requests.get(f'{HOST}/jd/search', params=param)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()['code'], 0)
self.assertGreater(len(response.json()['data']['results']), 0)