|
3#
楼主 |
发表于 2018-4-25 12:31:54
|
只看该作者
#!/usr/bin/env python
# _*_ coding:utf-8 _*_
import requests
import unittest
import json
class LoginAPiTest(unittest.TestCase):
def setUp(self):
print 'start !~~'
def tearDown(self):
print 'end !~~'
def login_verify(self,userName,password):
url = "http://192.168.18.17:3102/user/V1/oper/logn/login.json"
headers = {
'cliv': "1",
'ctype': "1"
}
data={
"userName":userName,
"password":password
}
res = requests.post(url, data=data,headers=headers)
return res.text
def test_login_success(self):
r=self.login_verify("S09208","123qwe")
r1 = json.JSONDecoder().decode(r)
self.assertEqual(r1['code'],1)
def test_login_error_username(self):
r=self.login_verify("1","123qwe")
r1 = json.JSONDecoder().decode(r)
self.assertEqual(r1['code'],2)
if __name__ == '__main__':
unittest.main() |
|