Skip to content

Commit a668973

Browse files
committed
添加测试,不包含本地测试
1 parent 0203568 commit a668973

File tree

7 files changed

+88
-234
lines changed

7 files changed

+88
-234
lines changed

.gitattributes

Lines changed: 0 additions & 22 deletions
This file was deleted.

.gitignore

Lines changed: 17 additions & 211 deletions
Original file line numberDiff line numberDiff line change
@@ -1,215 +1,21 @@
1-
#################
2-
## Eclipse
3-
#################
4-
5-
*.pydevproject
6-
.project
7-
.metadata
8-
bin/
9-
tmp/
10-
*.tmp
11-
*.bak
12-
*.swp
13-
*~.nib
14-
local.properties
15-
.classpath
16-
.settings/
17-
.loadpath
18-
19-
# External tool builders
20-
.externalToolBuilders/
21-
22-
# Locally stored "Eclipse launch configurations"
23-
*.launch
24-
25-
# CDT-specific
26-
.cproject
27-
28-
# PDT-specific
29-
.buildpath
30-
31-
32-
#################
33-
## Visual Studio
34-
#################
35-
36-
## Ignore Visual Studio temporary files, build results, and
37-
## files generated by popular Visual Studio add-ons.
38-
39-
# User-specific files
40-
*.suo
41-
*.user
42-
*.sln.docstates
43-
44-
# Build results
45-
46-
[Dd]ebug/
47-
[Rr]elease/
48-
x64/
1+
.coverage
2+
MANIFEST
3+
coverage.xml
4+
nosetests.xml
5+
junit-report.xml
6+
pylint.txt
7+
toy.py
8+
tox.ini
9+
violations.pyflakes.txt
10+
cover/
4911
build/
50-
[Bb]in/
51-
[Oo]bj/
52-
53-
# MSTest test Results
54-
[Tt]est[Rr]esult*/
55-
[Bb]uild[Ll]og.*
56-
57-
*_i.c
58-
*_p.c
59-
*.ilk
60-
*.meta
61-
*.obj
62-
*.pch
63-
*.pdb
64-
*.pgc
65-
*.pgd
66-
*.rsp
67-
*.sbr
68-
*.tlb
69-
*.tli
70-
*.tlh
71-
*.tmp
72-
*.tmp_proj
73-
*.log
74-
*.vspscc
75-
*.vssscc
76-
.builds
77-
*.pidb
78-
*.log
79-
*.scc
80-
81-
# Visual C++ cache files
82-
ipch/
83-
*.aps
84-
*.ncb
85-
*.opensdf
86-
*.sdf
87-
*.cachefile
88-
89-
# Visual Studio profiler
90-
*.psess
91-
*.vsp
92-
*.vspx
93-
94-
# Guidance Automation Toolkit
95-
*.gpState
96-
97-
# ReSharper is a .NET coding add-in
98-
_ReSharper*/
99-
*.[Rr]e[Ss]harper
100-
101-
# TeamCity is a build add-in
102-
_TeamCity*
103-
104-
# DotCover is a Code Coverage Tool
105-
*.dotCover
106-
107-
# NCrunch
108-
*.ncrunch*
109-
.*crunch*.local.xml
110-
111-
# Installshield output folder
112-
[Ee]xpress/
113-
114-
# DocProject is a documentation generator add-in
115-
DocProject/buildhelp/
116-
DocProject/Help/*.HxT
117-
DocProject/Help/*.HxC
118-
DocProject/Help/*.hhc
119-
DocProject/Help/*.hhk
120-
DocProject/Help/*.hhp
121-
DocProject/Help/Html2
122-
DocProject/Help/html
123-
124-
# Click-Once directory
125-
publish/
126-
127-
# Publish Web Output
128-
*.Publish.xml
129-
*.pubxml
130-
131-
# NuGet Packages Directory
132-
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
133-
#packages/
134-
135-
# Windows Azure Build Output
136-
csx
137-
*.build.csdef
138-
139-
# Windows Store app package directory
140-
AppPackages/
141-
142-
# Others
143-
sql/
144-
*.Cache
145-
ClientBin/
146-
[Ss]tyle[Cc]op.*
147-
~$*
148-
*~
149-
*.dbmdl
150-
*.[Pp]ublish.xml
151-
*.pfx
152-
*.publishsettings
153-
154-
# RIA/Silverlight projects
155-
Generated_Code/
156-
157-
# Backup & report files from converting an old project file to a newer
158-
# Visual Studio version. Backup files are not needed, because we have git ;-)
159-
_UpgradeReport_Files/
160-
Backup*/
161-
UpgradeLog*.XML
162-
UpgradeLog*.htm
163-
164-
# SQL Server files
165-
App_Data/*.mdf
166-
App_Data/*.ldf
167-
168-
#############
169-
## Windows detritus
170-
#############
171-
172-
# Windows image file caches
173-
Thumbs.db
174-
ehthumbs.db
175-
176-
# Folder config file
177-
Desktop.ini
178-
179-
# Recycle Bin used on file shares
180-
$RECYCLE.BIN/
181-
182-
# Mac crap
183-
.DS_Store
184-
185-
186-
#############
187-
## Python
188-
#############
189-
190-
*.py[co]
191-
192-
# Packages
12+
docs/_build
13+
requests.egg-info/
14+
*.pyc
15+
*.swp
19316
*.egg
194-
*.egg-info
195-
dist/
196-
build/
197-
eggs/
198-
parts/
199-
var/
200-
sdist/
201-
develop-eggs/
202-
.installed.cfg
203-
204-
# Installer logs
205-
pip-log.txt
206-
207-
# Unit test / coverage reports
208-
.coverage
209-
.tox
17+
env/
21018

211-
#Translations
212-
*.mo
19+
.workon
21320

214-
#Mr Developer
215-
.mr.developer.cfg
21+
test/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ChinaAPI
22
========
33

4-
###目前存在的API库:###
4+
###目前已有的API Python SDK:###
55
* 新浪微博:https://github.com/michaelliao/sinaweibopy
66
* 腾讯微博:https://github.com/upbit/tweibo-pysdk
77
* 淘宝:https://github.com/sempr/taobaopy

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# coding=utf-8

tests/test_qq_weibo.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# coding=utf-8
2+
from unittest import TestCase
3+
from chinaapi.qq_weibo import APIClient, OAuth2Handler, APIError
4+
5+
6+
# 返回text是unicode,设置默认编码为utf8
7+
import sys
8+
reload(sys)
9+
sys.setdefaultencoding('utf8')
10+
11+
12+
# 换成你的 APPKEY
13+
APP_KEY = ""
14+
APP_SECRET = ""
15+
CALLBACK_URL = ""
16+
ACCESS_TOKEN = ""
17+
OPENID = ""
18+
19+
20+
class QQWeiboTest(TestCase):
21+
def setUp(self):
22+
oauth = OAuth2Handler()
23+
oauth.set_app_key_secret(APP_KEY, APP_SECRET, CALLBACK_URL)
24+
oauth.set_access_token(ACCESS_TOKEN)
25+
oauth.set_openid(OPENID)
26+
self.client = APIClient(oauth)
27+
28+
def test_without_app_key(self):
29+
with self.assertRaises(APIError) as cm:
30+
r = self.client.get.t__show(format="json", id=301041004850688)
31+
self.assertEqual(u'missing parameter', cm.exception.result.msg)

tests/test_sina_weibo.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# coding=utf-8
2+
from unittest import TestCase
3+
from chinaapi.sina_weibo import APIClient, APIError
4+
5+
6+
APP_KEY = ""
7+
APP_SECRET = ""
8+
CALLBACK_URL = ""
9+
ACCESS_TOKEN = ""
10+
11+
12+
class SinaWeiboTest(TestCase):
13+
def setUp(self):
14+
self.client = APIClient(APP_KEY, APP_SECRET, CALLBACK_URL)
15+
16+
def test_without_app_key(self):
17+
with self.assertRaises(APIError) as cm:
18+
self.client.statuses.user_timeline.get()
19+
self.assertEqual(u'source paramter(appkey) is missing', cm.exception.error)

tests/test_taobao.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# coding=utf-8
2+
from unittest import TestCase
3+
from chinaapi.taobao import APIClient, APIError
4+
5+
6+
APP_KEY = ""
7+
APP_SECRET = ""
8+
CALLBACK_URL = ""
9+
ACCESS_TOKEN = ""
10+
11+
12+
class SinaWeiboTest(TestCase):
13+
def setUp(self):
14+
self.client = APIClient(APP_KEY, APP_SECRET)
15+
16+
def test_without_app_key(self):
17+
with self.assertRaises(APIError) as cm:
18+
self.client.items_get(nicks='kamozi', fields='num_iid,title,price', page_no=1, page_size=2)
19+
self.assertEqual(u'Missing app key', cm.exception.msg)

0 commit comments

Comments
 (0)