diff --git a/orangecontrib/text/guardian.py b/orangecontrib/text/guardian.py index d7222d41e..a8b1fa6ba 100644 --- a/orangecontrib/text/guardian.py +++ b/orangecontrib/text/guardian.py @@ -18,6 +18,7 @@ import requests import math import json +import os from Orange import data @@ -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) diff --git a/orangecontrib/text/tests/test_guardian.py b/orangecontrib/text/tests/test_guardian.py index 483b08348..72289f1e9 100644 --- a/orangecontrib/text/tests/test_guardian.py +++ b/orangecontrib/text/tests/test_guardian.py @@ -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):