Skip to content

Commit 6381f02

Browse files
committed
Removed hardcoded API token and moved it to config.py
1 parent 11a2fdd commit 6381f02

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
22
.DS_Store
33
*.pyc
4+
config.py

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ First install the test requirements with the following command:
3535

3636
$ pip install -r test_requirements.txt
3737

38-
Unit and integration tests are configured to run using nose. From the project directory, simply run:
38+
Unit and functional tests are configured to run using nose. From the project directory, simply run:
3939

4040
$ nosetests

client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def request(self, url, token, api, fields=[], version=2):
1111
"""
1212
params = {"url": url, "token": token}
1313
response = requests.get(self.compose_url(api, version), params=params)
14-
print response.content
1514
obj = response.json()
1615
obj = self.select_fields_from_response(obj, fields)
1716
return obj

config.py.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Add your API token here to run examples:
2+
3+
API_TOKEN = "SOME_TOKEN"

example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from client import DiffbotClient
2+
from config import API_TOKEN
23
import pprint
34

45
diffbot = DiffbotClient()
56
url = "http://shichuan.github.io/javascript-patterns/"
6-
token = "3c66f28f72ea40c1b02e6a4cc195b07e"
7+
token = API_TOKEN
78
api = "article"
89
version = 2
910

tests/unit_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def tearDown(self):
3737

3838
def test_article_api(self):
3939
url = "http://www.xconomy.com/san-francisco/2012/07/25/diffbot-is-using-computer-vision-to-reinvent-the-semantic-web/"
40-
token = "3c66f28f72ea40c1b02e6a4cc195b07e"
40+
token = "SOME_TOKEN"
4141
api = "article"
4242
version = 2
4343
response = self.client.request(url, token, api, version=version)
@@ -46,7 +46,7 @@ def test_article_api(self):
4646

4747
def test_frontpage_api(self):
4848
url = "http://www.huffingtonpost.com/"
49-
token = "3c66f28f72ea40c1b02e6a4cc195b07e"
49+
token = "SOME_TOKEN"
5050
api = "frontpage"
5151
version = 2
5252
response = self.client.request(url, token, api, version=version)
@@ -55,7 +55,7 @@ def test_frontpage_api(self):
5555

5656
def test_product_api(self):
5757
url = "http://www.overstock.com/Home-Garden/iRobot-650-Roomba-Vacuuming-Robot/7886009/product.html"
58-
token = "3c66f28f72ea40c1b02e6a4cc195b07e"
58+
token = "SOME_TOKEN"
5959
api = "product"
6060
version = 2
6161
response = self.client.request(url, token, api, version=version)
@@ -64,7 +64,7 @@ def test_product_api(self):
6464

6565
def test_image_api(self):
6666
url = "http://www.google.com/"
67-
token = "3c66f28f72ea40c1b02e6a4cc195b07e"
67+
token = "SOME_TOKEN"
6868
api = "image"
6969
version = 2
7070
response = self.client.request(url, token, api, version=version)
@@ -73,7 +73,7 @@ def test_image_api(self):
7373

7474
def test_analyze_api(self):
7575
url = "http://www.twitter.com/"
76-
token = "3c66f28f72ea40c1b02e6a4cc195b07e"
76+
token = "SOME_TOKEN"
7777
api = "analyze"
7878
version = 2
7979
response = self.client.request(url, token, api, version=version)

0 commit comments

Comments
 (0)