Skip to content

Commit

Permalink
2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jellyfrank committed Dec 13, 2019
1 parent a03f15a commit 1e81677
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2019-08-21
# @Author : Kevin Kong (kfx2007@163.com)

Expand Down
2 changes: 1 addition & 1 deletion sf/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
# coding:utf-8
# @Time : 2019-08-21
# @Author : Kevin Kong (kfx2007@163.com)

Expand Down
6 changes: 2 additions & 4 deletions sf/comm/comm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2019-08-21
# @Author : Kevin Kong (kfx2007@163.com)

Expand Down Expand Up @@ -56,7 +56,7 @@ def gen_xmldata(self, data):
el.set(key, value)
body.append(el)
root.append(body)
return etree.tostring(root, xml_declaration=True, encoding="UTF-8").decode("utf-8")
return etree.tostring(root, xml_declaration=True)

def _parse(self, root):
data = {}
Expand Down Expand Up @@ -102,7 +102,5 @@ def post(self, data):
"verifyCode": self.gen_verifycode(xml)
}

print(post_data)
response = requests.post(URL, post_data)
print(response.content.decode('utf-8'))
return self.parse_response(response.content)
2 changes: 1 addition & 1 deletion sf/order/order.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
# coding:utf-8
# @Time : 2019-08-21
# @Author : Kevin Kong (kfx2007@163.com)

Expand Down
Empty file added tests/__init__.py
Empty file.
18 changes: 10 additions & 8 deletions tests/test_order.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2019-08-21
# @Author : Kevin Kong (kfx2007@163.com)

Expand All @@ -13,19 +13,21 @@ class TestOrder(unittest.TestCase):
def test_order(self):
"""测试下单"""
# 顺丰接口不允许重复下单,因此拿到结果就算通过
res = self.sf.order.create_order("SFKD-20160219000021", "测试公司",
"张三", "18512345678", "丰县", "北京市昌平区", "15112345678")
self.assertIn(res["result"],[1,0])
res = self.sf.order.create_order("SFKD-20160219000021", u"测试公司",
u"张三", "18512345678", u"丰县", u"北京市昌平区", "15112345678")
self.assertIn(res["result"], [1, 0])

def test_cancel_order(self):
"""测试取消订单"""

res = self.sf.order.confirm_order("SFKD-20160219000021","444017832497","2")
self.assertIn(res["result"],[1,0])

res = self.sf.order.confirm_order(
"SFKD-20160219000021", "444017832497", "2")
self.assertIn(res["result"], [1, 0])

def test_get_order(self):
"""测试订单查询接口"""
self.assertEquals(self.sf.order.get_order("SFKD-20160219000021"),1)
res = self.sf.order.get_order("SFKD-20160219000021")
self.assertIn(res["result"], [1, 0])


if __name__ == "__main__":
Expand Down

0 comments on commit 1e81677

Please sign in to comment.