File tree Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 60
60
61
61
# Tests
62
62
LOAD_WINDOWS_TEST_SQL = False
63
+
64
+ # External APIs
65
+ API_WIKIDATA = 'https://www.wikidata.org/w/api.php'
66
+ API_GEONAMES = 'http://api.geonames.org/get'
Original file line number Diff line number Diff line change 4
4
import xmltodict
5
5
from flask import g
6
6
7
+ from openatlas import app
8
+
7
9
8
10
def fetch_geonames (id_ : str ) -> dict [str , Any ]:
9
- url = 'http://api.geonames.org/get'
10
11
params = {
11
12
'geonameId' : {id_ },
12
13
'username' : {g .settings ['geonames_username' ]}}
13
14
try :
14
- data = requests .get (url , params , timeout = 10 ).content
15
+ data = requests .get (
16
+ app .config ['API_GEONAMES' ],
17
+ params ,
18
+ timeout = 10 ).content
15
19
data_dict = xmltodict .parse (data )['geoname' ]
16
20
except Exception : # pragma: no cover
17
21
return {}
Original file line number Diff line number Diff line change 3
3
import requests
4
4
from flask import g
5
5
6
+ from openatlas import app
6
7
from openatlas .display .util import link
7
8
8
9
@@ -11,15 +12,17 @@ def add_resolver_url(id_: str) -> str:
11
12
12
13
13
14
def fetch_wikidata (id_ : str ) -> dict [str , Any ]:
14
- url = 'https://www.wikidata.org/w/api.php'
15
15
params = {
16
16
'action' : 'wbgetentities' ,
17
17
'ids' : id_ ,
18
18
'format' : 'json' ,
19
19
'languages' : 'en' }
20
20
info = {}
21
21
try :
22
- data = requests .get (url , params = params , timeout = 10 ).json ()
22
+ data = requests .get (
23
+ app .config ['API_WIKIDATA' ],
24
+ params = params ,
25
+ timeout = 10 ).json ()
23
26
except Exception : # pragma: no cover
24
27
return {}
25
28
try :
Original file line number Diff line number Diff line change @@ -26,8 +26,7 @@ def test_reference_system(self) -> None:
26
26
data = {'id_' : '1158433263' })
27
27
assert b'Abasgulijev' in rv .data
28
28
29
- rv : Any = self .app .get (
30
- url_for ('insert' , class_ = 'reference_system' ))
29
+ rv = self .app .get (url_for ('insert' , class_ = 'reference_system' ))
31
30
assert b'resolver URL' in rv .data
32
31
33
32
rv = self .app .post (
You can’t perform that action at this time.
0 commit comments