#coding=utf-8
import json
import re
import unittest
import urllib2, urllib
from django.http import response
#################
##Author:Chen
##Date:2015-04-13
##Title:
#################
class TestprofileIndex(unittest.TestCase):
'''Cxx服务:接口文档:'''
def setUp(self):
'''测试前的准备工作'''
pass
def tearDown(self):
'''测试结束后的清除工作'''
pass
def testProfileIndexSucc_singleParametertest(self):
'1.测试目的:查看'
expected_code ='11'
#print 'code1:',(type(code1))
data = {'itemid':'1005051809031027_-_'}
res1 = urllib2.urlopen(url = ' http://.xx.com/component/likescard/profileindex.json?source=3818214747',data=urllib.urlencode(data)).read()
getactual_code = re.findall('card_type":(.*?),',res1)
assert getactual_code[0] == expected_code,'显示错误'
def testProfileIndexSucc_andoidParameter(self):
'2.测试目的:查看'
expected_code2 ='11'
#print 'code1:',(type(code1))
data = {'itemid':'1005051809031027_-_',
'uid':'5175065084',
'v_p':'0',
'c':'android'}
res2 = urllib2.urlopen(url = ' http://xx.com/component/likescard/profileindex.json?source=3818214747',data=urllib.urlencode(data)).read()
getactual_code2 = re.findall('card_type":(.*?),',res2)
assert getactual_code2[0] == expected_code2,'显示错误'
def suite():
return unittest.makeSuite(TestprofileIndex,"test")
#运行所有test开头的用例顺序:英文
if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
#unittest.main()
runner = unittest.TextTestRunner(verbosity = 2)
runner.run(suite())