Skip to content

Commit 0cc8497

Browse files
committed
add tests to 99% coverage
1 parent 35f3348 commit 0cc8497

3 files changed

Lines changed: 114 additions & 3 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
*.egg-info
33
*__pycache__
44
build/
5-
dist/
5+
dist/
6+
.coverage

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool:pytest]
2-
addopts = --flake8
2+
addopts = --flake8 --cov
33
flake8-ignore =
44
*.py F541 W503 W504
55
tests/* F401

tests/test_api.py

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,119 @@ def test_get_documents():
5656
]
5757

5858

59-
def test_get_values():
59+
def test_get_values_multiple_series():
60+
results = rc.get_values(
61+
series=[1, 2], jurisdiction=38, date=1970, verbose=1
62+
)
63+
assert order_results(results, 'seriesValue') == [405647.0, 35420432.0]
64+
65+
66+
def test_get_values_incorrect_series():
67+
results = rc.get_values(series=None, jurisdiction=38, date=2019)
68+
assert not results
69+
70+
71+
def test_get_values_multiple_jurisdictions():
72+
results = rc.get_values(series=1, jurisdiction=[58, 59], date=2019)
73+
assert order_results(results, 'seriesValue') == [52569.0, 107063.0]
74+
75+
76+
def test_get_values_all_industries():
77+
results = rc.get_values(
78+
series=9, jurisdiction=58, date=2019, industry='all', filtered=False
79+
)
80+
assert order_results(results, 'seriesValue') == [
81+
16.487800191811402, 28.080800290597836, 36.27130037093593,
82+
36.53810011051246, 40.113500030507566, 45.02970027324045,
83+
48.842899827621295, 50.17920009633963, 72.05880061667267,
84+
82.19629916545819
85+
]
86+
87+
88+
def test_get_values_multiple_industries():
89+
results = rc.get_values(
90+
series=9, jurisdiction=58, date=2019, industry=['111', '325', '326']
91+
)
92+
assert order_results(results, 'seriesValue') == [
93+
255.2682025779941, 649.0292048707197, 1858.660280573211
94+
]
95+
96+
97+
def test_get_values_one_industry():
98+
results = rc.get_values(
99+
series=9, jurisdiction=58, date=2019, industry='111', summary=False
100+
)
101+
# No document-level industry results exists for this jurisdiction
102+
assert not results
103+
104+
105+
def test_get_values_incorrect_jurisdiction():
106+
results = rc.get_values(series=1, jurisdiction=None, date=2019)
107+
assert not results
108+
109+
110+
def test_get_values_date_range():
60111
results = rc.get_values(series=1, jurisdiction=38, date=[1970, 2019])
61112
assert order_results(results, 'seriesValue') == [
62113
405647.0, 416532.0, 452114.0, 470561.0, 500133.0,
63114
524992.0, 548579.0, 572123.0, 581408.0, 615181.0
64115
]
116+
117+
118+
def test_get_values_multiple_dates():
119+
results = rc.get_values(
120+
series=1, jurisdiction=38, date=[1970, 1980, 1990, 2000]
121+
)
122+
assert order_results(results, 'seriesValue') == [
123+
405647.0, 633754.0, 772537.0, 853661.0
124+
]
125+
126+
127+
def test_get_values_incorrect_dates():
128+
results = rc.get_values(series=1, jurisdiction=38, date=None)
129+
assert not results
130+
131+
132+
def test_get_values_country():
133+
results = rc.get_values(series=1, jurisdiction=38, date=2019, country=True)
134+
assert order_results(results, 'seriesValue') == [
135+
43940.0, 52569.0, 60086.0, 63203.0, 63735.0,
136+
70969.0, 78676.0, 92522.0, 104562.0, 107063.0
137+
]
138+
139+
140+
def test_get_values_agency():
141+
results = rc.get_values(series=91, jurisdiction=38, date=2019, agency=195)
142+
assert order_results(results, 'seriesValue') == [62.0]
143+
144+
145+
def test_get_values_multiple_agencies():
146+
results = rc.get_values(
147+
series=91, jurisdiction=38, date=2019, agency=[111, 99]
148+
)
149+
assert order_results(results, 'seriesValue') == [34167.0, 91227.0]
150+
151+
152+
def test_list_document_types():
153+
results = rc.list_document_types()
154+
assert results['All Regulations'] == 3
155+
156+
157+
def test_list_series():
158+
results = rc.list_series()
159+
assert results['Conditionals'] == 135
160+
161+
162+
def test_list_agencies():
163+
results = rc.list_agencies()
164+
assert results['Administrative Conference of the United States'] == 195
165+
166+
167+
def test_list_jurisdictions():
168+
results = rc.list_jurisdictions()
169+
assert results['Alabama'] == 59
170+
171+
172+
def test_list_industries():
173+
results = rc.list_industries(jurisdictionID=38)
174+
assert results['Wood Container and Pallet Manufacturing'] == '321920'

0 commit comments

Comments
 (0)