-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·57 lines (47 loc) · 1.61 KB
/
test.py
File metadata and controls
executable file
·57 lines (47 loc) · 1.61 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
import config
import time
import ast
from app import create_app
app = create_app()
class TestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.app = app.test_client()
def setUp(self):
pass
def tearDown(self):
pass
def test_requests(self):
for key in config.NEWS_TYPE.keys():
# 缓存列表
if key not in ['xy', 'jw', 'xm']:
origin = 'xb'
faculty = key
else:
origin = key
faculty = ''
for page in range(1, 2):
qurey_url = "%s?news_type=%s&page=%s&faculty=%s&force_reload=%s" % (
config.LIST_URL, origin, page, faculty, '1')
ret = self.app.get(qurey_url)
data = bytes.decode(ret.data)
print(qurey_url)
for content in ast.literal_eval(data)['data']:
url = content['url']
if origin == 'xm':
self.app.get(
"%s?type=%s&url=%s&articleid=%s&force_reload=%s" %
(config.DETAIL_URL, origin, url,content['articleid'], '1'))
else:
self.app.get(
"%s?type=%s&url=%s&force_reload=%s" %
(config.DETAIL_URL, origin, url, '1'))
print(url)
time.sleep(1)
time.sleep(1)
if __name__ == '__main__':
with app.app_context():
unittest.main()