Skip to content

Commit 8ef08cf

Browse files
committed
require jurisdiction in agencies calls
1 parent 5126475 commit 8ef08cf

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
*__pycache__
44
build/
55
dist/
6-
.coverage
6+
.coverage
7+
*tox*
8+
.python-version

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
__The current version of RegCensusAPI is only compatible with Python 3.6 and newer.__
2+
13
# RegCensus API
24

35
## Introduction

regcensus/api.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def get_series(seriesID=''):
160160
return clean_columns(output)
161161

162162

163-
def get_agencies(agencyID=''):
163+
def get_agencies(jurisdictionID=''):
164164
"""
165165
Get metadata for all or one specific agency
166166
@@ -169,7 +169,9 @@ def get_agencies(agencyID=''):
169169
Returns: pandas dataframe with the metadata
170170
"""
171171
output = json_normalize(
172-
requests.get(URL + f'/agencies/{agencyID}').json())
172+
requests.get(
173+
URL + (f'/agencies/jurisdiction?'
174+
f'jurisdictions={jurisdictionID}')).json())
173175
return clean_columns(output)
174176

175177

@@ -257,11 +259,12 @@ def list_series():
257259
return dict(sorted({s["seriesName"]: s["seriesID"] for s in json}.items()))
258260

259261

260-
def list_agencies():
262+
def list_agencies(jurisdictionID):
261263
"""
262264
Returns: dictionary containing names of agencies and associated IDs
263265
"""
264-
json = requests.get(URL + '/agencies').json()
266+
json = requests.get(
267+
URL + f'/agencies/jurisdiction?jurisdictions={jurisdictionID}').json()
265268
return dict(sorted({
266269
a["agencyName"]: a["agencyID"]
267270
for a in json if a["agencyName"]}.items()))

tests/test_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def test_get_series():
2020

2121

2222
def test_get_agencies():
23-
results = rc.get_agencies()
23+
results = rc.get_agencies(38)
2424
assert order_results(results, 'agencyID') == [
25-
0, 1, 64, 65, 66, 67, 68, 69, 70, 71
25+
64, 65, 66, 67, 68, 69, 70, 71, 72, 73
2626
]
2727

2828

@@ -196,7 +196,7 @@ def test_list_series():
196196

197197

198198
def test_list_agencies():
199-
results = rc.list_agencies()
199+
results = rc.list_agencies(38)
200200
assert results['Administrative Conference of the United States'] == 195
201201

202202

0 commit comments

Comments
 (0)