Skip to content

Commit

Permalink
guardian: get api key from env (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcv authored and kernc committed Jul 19, 2018
1 parent d05a64c commit 8bb4268
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion orangecontrib/text/guardian.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import requests
import math
import json
import os

from Orange import data

Expand Down Expand Up @@ -155,7 +156,8 @@ def search(self, query, from_date=None, to_date=None, max_documents=None,


if __name__ == '__main__':
credentials = TheGuardianCredentials('test')
key = os.getenv('THE_GUARDIAN_API_KEY', 'test')
credentials = TheGuardianCredentials(key)
print(credentials.valid)
api = TheGuardianAPI(credentials=credentials)
c = api.search('refugees', max_documents=10)
Expand Down
3 changes: 2 additions & 1 deletion orangecontrib/text/tests/test_guardian.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import unittest
import os

from datetime import date, datetime

from orangecontrib.text import guardian


API_KEY = 'test'
API_KEY = os.getenv('THE_GUARDIAN_API_KEY', 'test')


class TestCredentials(unittest.TestCase):
Expand Down

0 comments on commit 8bb4268

Please sign in to comment.