@@ -19,7 +19,7 @@ def test_wrong_params_combinations():
1919 my_data = load (
2020 dummy_df ,
2121 idx = ("Control 1" , "Test 1" ),
22- delta2 = True ,
22+ delta2 = True
2323 )
2424 assert error_msg in str (excinfo .value )
2525
@@ -30,7 +30,7 @@ def test_wrong_params_combinations():
3030 x = ["Control 1" , "Control 1" ],
3131 y = "Test 1" ,
3232 delta2 = True ,
33- mini_meta = True ,
33+ mini_meta = True
3434 )
3535
3636 assert error_msg in str (excinfo .value )
@@ -42,7 +42,7 @@ def test_wrong_params_combinations():
4242 x = ["Control 1" , "Control 1" ],
4343 y = "Test 1" ,
4444 delta2 = True ,
45- proportional = True ,
45+ proportional = True
4646 )
4747
4848 assert error_msg in str (excinfo .value )
@@ -53,7 +53,164 @@ def test_wrong_params_combinations():
5353 dummy_df ,
5454 x = ["Control 1" , "Control 1" ],
5555 idx = ("Control 1" , "Test 1" ),
56+ delta2 = True
57+ )
58+
59+ assert error_msg in str (excinfo .value )
60+
61+ error_msg = "`id_col` must be specified if `paired` is assigned with a not NoneType value."
62+ with pytest .raises (IndexError ) as excinfo :
63+ my_data = load (
64+ dummy_df , idx = ("Control 1" , "Test 1" ), paired = "baseline"
65+ )
66+
67+ assert error_msg in str (excinfo .value )
68+
69+ error_msg = "`delta2` is True but `y` is not indicated."
70+ with pytest .raises (ValueError ) as excinfo :
71+ my_data = load (
72+ dummy_df ,
73+ x = ["Control 1" , "Control 1" ],
74+ delta2 = True
75+ )
76+
77+
78+ def test_param_validations ():
79+ error_msg = "`idx` contains duplicated groups. Please remove any duplicates and try again." .format (N )
80+ with pytest .raises (ValueError ) as excinfo :
81+ my_data = load (
82+ dummy_df , idx = ("Control 1" , "Control 1" )
83+ )
84+
85+ assert error_msg in str (excinfo .value )
86+
87+ err0 = "Groups are repeated across tuples,"
88+ err1 = " or a tuple has repeated groups in it."
89+ err2 = " Please remove any duplicates and try again."
90+ error_msg = err0 + err1 + err2
91+ with pytest .raises (ValueError ) as excinfo :
92+ my_data = load (
93+ dummy_df , idx = (("Control 1" , "Control 1" , "Test 1" ), ("Control 2" , "Test 2" ))
94+ )
95+
96+ assert error_msg in str (excinfo .value )
97+
98+ wrong_idx = ("Control 1" , ("Control 1" , "Test 1" ))
99+ error_msg = "There seems to be a problem with the idx you " "entered--{}." .format (wrong_idx )
100+ with pytest .raises (ValueError ) as excinfo :
101+ my_data = load (
102+ dummy_df , idx = wrong_idx
103+ )
104+
105+ assert error_msg in str (excinfo .value )
106+
107+ wrong_paired = 'not_valid'
108+ error_msg = "{} assigned for `paired` is not valid." .format (wrong_paired )
109+ with pytest .raises (ValueError ) as excinfo :
110+ my_data = load (
111+ dummy_df , idx = ("Control 1" , "Test 1" ), paired = wrong_paired , id_col = "ID"
112+ )
113+
114+ assert error_msg in str (excinfo .value )
115+
116+
117+ wrong_id_col = 'not_valid'
118+ error_msg = "{} is not a column in `data`. " .format (wrong_id_col )
119+ with pytest .raises (IndexError ) as excinfo :
120+ my_data = load (
121+ dummy_df , idx = ("Control 1" , "Test 1" ), paired = "baseline" , id_col = wrong_id_col
122+ )
123+
124+ assert error_msg in str (excinfo .value )
125+
126+ wrong_idx_mmeta = ("Control 1" , "Test 1" , "Test 2" )
127+ err0 = "`mini_meta` is True, but `idx` ({})" .format (wrong_idx_mmeta )
128+ err1 = "does not contain exactly 2 unique columns."
129+ error_msg = err0 + err1
130+ with pytest .raises (ValueError ) as excinfo :
131+ my_data = load (
132+ dummy_df , idx = wrong_idx_mmeta , mini_meta = True
133+ )
134+
135+ assert error_msg in str (excinfo .value )
136+
137+ wrong_idx_mmeta = (("Control 1" , "Test 1" , "Test 2" ), ("Control 1" , "Control 2" , "Test 3" ))
138+ err0 = "`mini_meta` is True, but `idx` ({})" .format (wrong_idx_mmeta )
139+ err1 = "does not contain exactly 2 unique columns."
140+ error_msg = err0 + err1
141+ with pytest .raises (ValueError ) as excinfo :
142+ my_data = load (
143+ dummy_df , idx = wrong_idx_mmeta , mini_meta = True
144+ )
145+
146+ assert error_msg in str (excinfo .value )
147+
148+ wrong_x = ["Control 1" , "Control 1" , "Control 2" ]
149+ error_msg = "`delta2` is True but the number of variables indicated by `x` is {}." .format (len (wrong_x ))
150+ with pytest .raises (ValueError ) as excinfo :
151+ my_data = load (
152+ dummy_df , x = wrong_x , y = "Test 1" , delta2 = True
153+ )
154+
155+ assert error_msg in str (excinfo .value )
156+
157+ wrong_x = ["Control 4" , "Control 5" ]
158+ error_msg = "is not a column in `data`. Please check."
159+ with pytest .raises (IndexError ) as excinfo :
160+ my_data = load (
161+ dummy_df , x = wrong_x , y = "Test 1" , delta2 = True
162+ )
163+
164+ assert error_msg in str (excinfo .value )
165+
166+ wrong_y = "Test 3"
167+ error_msg = "is not a column in `data`. Please check."
168+ with pytest .raises (IndexError ) as excinfo :
169+ my_data = load (
170+ dummy_df , x = ["Control 1" , "Control 2" ], y = wrong_y , delta2 = True
171+ )
172+
173+ assert error_msg in str (excinfo .value )
174+
175+ wrong_experiment = "not_valid"
176+ error_msg = "is not a column in `data`. Please check."
177+ with pytest .raises (IndexError ) as excinfo :
178+ my_data = load (
179+ dummy_df ,
180+ x = ["Control 1" , "Control 1" ],
181+ y = "Test 1" ,
182+ delta2 = True ,
183+ experiment = wrong_experiment
184+ )
185+
186+ assert error_msg in str (excinfo .value )
187+
188+ #TODO experiment and experiment_label are different
189+
190+ wrong_experiment_label = ["A" , "B" , "C" ]
191+ error_msg = "`experiment_label` does not have a length of 2."
192+ with pytest .raises (ValueError ) as excinfo :
193+ my_data = load (
194+ dummy_df ,
195+ x = ["Control 1" , "Control 1" ],
196+ y = "Test 1" ,
56197 delta2 = True ,
198+ experiment = "Control 1" ,
199+ experiment_label = wrong_experiment_label
57200 )
58201
59202 assert error_msg in str (excinfo .value )
203+
204+ wrong_x1_level = "not_valid"
205+ error_msg = "`x1_level` does not have a length of 2."
206+ with pytest .raises (ValueError ) as excinfo :
207+ my_data = load (
208+ dummy_df ,
209+ x = ["Control 1" , "Control 1" ],
210+ y = "Test 1" ,
211+ delta2 = True ,
212+ experiment = "Control 1" ,
213+ x1_level = wrong_x1_level
214+ )
215+
216+ assert error_msg in str (excinfo .value )
0 commit comments