Skip to content

Commit 8844d8d

Browse files
committed
adjust for new doctype IDs
1 parent 26fa490 commit 8844d8d

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

regcensus/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def get_values(series, jurisdiction, date, filtered=True, summary=True,
14-
documentType=3, agency=None, industry=None, dateIsRange=True,
14+
documentType=1, agency=None, industry=None, dateIsRange=True,
1515
country=False, industryType='3-Digit',
1616
download=False, verbose=0):
1717
"""
@@ -232,7 +232,7 @@ def get_industries(jurisdictionID, verbose=0):
232232
return clean_columns(json_normalize(requests.get(url_call).json()))
233233

234234

235-
def get_documents(jurisdictionID, documentType=3, verbose=0):
235+
def get_documents(jurisdictionID, documentType=1, verbose=0):
236236
"""
237237
Get metadata for documents available in a specific jurisdiction, optional
238238
filtering by document type (see list_document_types() for options)

tests/test_api.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ def order_results(results, column, descending=False):
1515
def test_get_series():
1616
results = rc.get_series(verbose=1)
1717
assert order_results(results, 'seriesCode') == [
18-
'NY.GDP.MKTP.CD', 'NY.GDP.MKTP.KD', 'NY.GDP.MKTP.KD.ZG',
19-
'NY.GDP.PCAP.KD.ZG', 'RG_DRST0000001A', 'RG_HLC1000002A',
20-
'RG_OCL1000002A', 'RG_OCL1000002B', 'RG_OCL1000002C', 'RG_OCLI1000001A'
18+
'NY.GDP.MKTP.CD', 'NY.GDP.MKTP.CD', 'NY.GDP.MKTP.KD',
19+
'NY.GDP.MKTP.KD', 'NY.GDP.MKTP.KD.ZG', 'NY.GDP.MKTP.KD.ZG',
20+
'NY.GDP.PCAP.KD.ZG', 'NY.GDP.PCAP.KD.ZG', 'RG_DRST0000001A',
21+
'RG_HLC1000002A'
2122
]
2223

2324

@@ -36,15 +37,15 @@ def test_get_jurisdictions():
3637

3738

3839
def test_get_periods():
39-
results = rc.get_periods(38, documentType=3, verbose=1)
40+
results = rc.get_periods(38, documentType=1, verbose=1)
4041
assert order_results(results, 'recordsAvailable', descending=True) == [
4142
30696278, 30696278, 30696278, 30696278, 30696278,
4243
30696278, 30696278, 30696278, 30696278, 30696278
4344
]
4445

4546

4647
def test_get_periods_one_series():
47-
results = rc.get_periods(20, documentType=3, seriesID=19, verbose=1)
48+
results = rc.get_periods(20, documentType=1, seriesID=29, verbose=1)
4849
assert order_results(results, 'recordsAvailable') == [13]
4950

5051

@@ -156,13 +157,13 @@ def test_get_values_country():
156157

157158

158159
def test_get_values_agency():
159-
results = rc.get_values(series=91, jurisdiction=38, date=2019, agency=195)
160+
results = rc.get_values(series=13, jurisdiction=38, date=2019, agency=195)
160161
assert order_results(results, 'seriesValue') == [62.0]
161162

162163

163164
def test_get_values_all_agencies():
164165
results = rc.get_values(
165-
series=91, jurisdiction=38, date=2019, agency='all'
166+
series=13, jurisdiction=38, date=2019, agency='all'
166167
)
167168
assert order_results(results, 'seriesValue') == [
168169
0.0, 0.0, 1.0, 1.0, 5.0, 18.0, 33.0, 34.0, 50.0, 59.0
@@ -171,14 +172,14 @@ def test_get_values_all_agencies():
171172

172173
def test_get_values_multiple_agencies():
173174
results = rc.get_values(
174-
series=91, jurisdiction=38, date=2019, agency=[111, 99]
175+
series=13, jurisdiction=38, date=2019, agency=[111, 99]
175176
)
176177
assert order_results(results, 'seriesValue') == [34167.0, 91227.0]
177178

178179

179180
def test_get_values_download():
180181
results = rc.get_values(
181-
series=91, jurisdiction=38, date=2019, agency=195, download='test.csv'
182+
series=13, jurisdiction=38, date=2019, agency=195, download='test.csv'
182183
)
183184
assert not results
184185
assert os.path.exists('test.csv')
@@ -187,14 +188,14 @@ def test_get_values_download():
187188

188189
def test_get_values_incorrect_download(capsys):
189190
results = rc.get_values(
190-
series=91, jurisdiction=38, date=2019, agency=195, download=True
191+
series=13, jurisdiction=38, date=2019, agency=195, download=True
191192
)
192193
assert not results
193194
assert capsys.readouterr().out == 'Valid outpath required to download.\n'
194195

195196

196197
def test_get_values_error(capsys):
197-
results = rc.get_values(series=1, jurisdiction=38, date=1900)
198+
results = rc.get_values(series=1, jurisdiction=38, date=1900, verbose=1)
198199
assert not results
199200
assert capsys.readouterr().out == (
200201
'WARNING: SeriesValue was not found for the specified parameters. '
@@ -211,12 +212,12 @@ def test_get_values_error(capsys):
211212

212213
def test_list_document_types():
213214
results = rc.list_document_types()
214-
assert results['Regulation text: All regulations'] == 3
215+
assert results['Regulation text: All regulations'] == 1
215216

216217

217218
def test_list_series():
218219
results = rc.list_series()
219-
assert results['Complexity: Conditionals analysis'] == 135
220+
assert results['Complexity: Conditionals analysis'] == 53
220221

221222

222223
def test_list_agencies():

0 commit comments

Comments
 (0)