2019-01-08 09:04:40 +00:00
# coding=utf-8
import unittest
from collections import OrderedDict
import requests
from agency . agency_tools import proxy
from config . emailConf import sendEmail
2019-01-10 16:41:41 +00:00
from config . pushbearConf import sendPushBear
2019-01-08 09:04:40 +00:00
def _set_header_default ( ) :
header_dict = OrderedDict ( )
header_dict [ " Accept " ] = " */* "
header_dict [ " Accept-Encoding " ] = " gzip, deflate "
header_dict [ " X-Requested-With " ] = " superagent "
header_dict [
" User-Agent " ] = " Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1 "
header_dict [ " Content-Type " ] = " application/x-www-form-urlencoded; charset=UTF-8 "
class testAll ( unittest . TestCase ) :
def testProxy ( self ) :
"""
测试代理是否可用
: return :
"""
_proxy = proxy ( )
proxie = _proxy . setProxy ( )
url = " http://httpbin.org/ip "
rsp = requests . get ( url , proxies = proxie , timeout = 5 , headers = _set_header_default ( ) ) . content
print ( u " 当前代理ip地址为: {} " . format ( rsp ) )
def testEmail ( self ) :
"""
实测邮箱是否可用
: return :
"""
2019-01-14 14:35:36 +00:00
sendEmail ( u " 订票小助手测试一下 " )
2019-01-10 17:14:48 +00:00
2019-01-10 16:41:41 +00:00
def testPushbear ( self ) :
"""
实测pushbear是否可用
: return :
"""
2019-04-03 15:29:50 +00:00
sendPushBear ( u " pushbear 微信通知测试一下 " )
2019-01-08 09:04:40 +00:00
# def testConfig(self):
# """
# 测试config是否配置正确
# :return:
# """
if __name__ == ' __main__ ' :
unittest . main ( )