Skip to content

Commit e982fff

Browse files
George RobertsonGeorge Robertson
authored andcommitted
added check_consistent_submissions_test
1 parent d4879f8 commit e982fff

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
from codonPython.check_consistent_submissions import check_consistent_submissions
2+
import pandas as pd
3+
import numpy
4+
import pytest
5+
6+
@pytest.mark.parametrize("data, national_geog_level, geography_col, submissions_col, measure_col, expected", [
7+
(
8+
pd.DataFrame({
9+
"Geog" : ["N" ,"N", "Region", "Region", "Local", "Local",],
10+
"measure" : ["m1", "m2", "m1", "m2", "m1", "m2",],
11+
"submissions" : [4, 2, 2, 1, 2, 1,],
12+
}),
13+
"N",
14+
"Geog",
15+
"submissions",
16+
"measure",
17+
True
18+
),
19+
(
20+
pd.DataFrame({
21+
"Org_Level" : ["National" ,"National", "Region", "Region", "Local", "Local",],
22+
"Measure" : ["m1", "m2", "m1", "m2", "m1", "m2",],
23+
"Value_Unsuppressed" : [4, 2, 3, 1, 2, 1,],
24+
}),
25+
"N",
26+
"Geog",
27+
"submissions",
28+
"measure",
29+
False
30+
)
31+
])
32+
33+
def each_consistent_measure_BAU(data, national_geog_level, geography_col, submissions_col, measure_col, expected):
34+
assert expected == check_consistent_submissions(data, geography_col, submissions_col, measure_col)
35+
36+
@pytest.mark.parametrize("data, national_geog_level, geography_col, submissions_col, measure_col",[
37+
(
38+
pd.DataFrame({
39+
"Geog" : ["N" ,"N", "Region", "Region", "Local", "Local",],
40+
"measure" : ["m1", "m2", "m1", "m2", "m1", "m2",],
41+
"submissions" : [4, 2, 2, 1, 2, 1,],
42+
}),
43+
1,
44+
"Geog",
45+
"submissions",
46+
"measure"
47+
),
48+
(
49+
pd.DataFrame({
50+
"Geog" : ["N", "N", "Region", "Region", "Local", "Local",],
51+
"measure" : ["m1", "m2", "m1", "m2", "m1", "m2",],
52+
"submissions" : [4, 2, 2, 1, 2, 1,],
53+
}),
54+
"N",
55+
False,
56+
"submissions",
57+
"measure"
58+
),
59+
(
60+
pd.DataFrame({
61+
"Geog" : ["N", "N", "Region", "Region", "Local", "Local",],
62+
"measure" : ["m1", "m2", "m2", "m2", "m1", "m2",],
63+
"submissions" : [4, 2, 2, 1, 2, 1,],
64+
}),
65+
"N",
66+
"Geog",
67+
4.2,
68+
"measure"
69+
)
70+
])
71+
72+
def test_each_consistent_submissions_valueErrors(data, national_geog_level, geography_col, submissions_col, measure_col):
73+
with pytest.raises(ValueError):
74+
check_consistent_submissions(data, national_geog_level, geography_col, submissions_col, measure_col)
75+
76+
@pytest.mark.parametrize("data, national_geog_level, geography_col, submissions_col, measure_col", [
77+
(
78+
pd.DataFrame({
79+
"Geog" : ["N" ,"N", "Region", "Region", "Local", "Local",],
80+
"measure" : ["m1", "m2", "m1", "m2", "m1", "m2",],
81+
"submissions" : [4, 2, 2, 1, 2, 1,],
82+
}),
83+
"N",
84+
"Geog",
85+
"submissions",
86+
"measurez"
87+
)
88+
])
89+
90+
def test_each_consistent_submissions_colError(data, national_geog_level, geography_col, submissions_col, measure_col):
91+
with pytest.raises(KeyError):
92+
check_consistent_submissions(data, national_geog_level, geography_col, submissions_col, measure_col)

0 commit comments

Comments
 (0)