@@ -218,30 +218,32 @@ def test_invalid_stats(self):
218218
219219 @patch ('futurex_openedx_extensions.dashboard.views.AggregatedCountsView._construct_result' )
220220 @ddt .data (
221- (None , '2024-01-01' , '2024-01-01' , 'Invalid aggregate_period: None' ),
222- ('day' , '2024-01-01' , '2024-01-01' , None ),
223- ('day' , '2024-01-01' , '2024-01-02' , None ),
224- ('day' , '2024-01-02' , '2024-01-01' , None ),
225- ('day' , None , '2024-01-01' , None ),
226- ('day' , '2024-01-02' , None , None ),
227- ('day' , None , None , None ),
228- ('invalid' , '2024-01-01' , '2024-01-02' , 'Invalid aggregate_period: invalid' ),
221+ (None , '2024-01-01' , '2024-01-01' , 'Invalid aggregate_period: None' , None ),
222+ ('day' , '2024-01-01' , '2024-01-01' , None , None ),
223+ ('day' , '2024-01-01' , '2024-01-02' , None , None ),
224+ ('day' , '2024-01-02' , '2024-01-01' , None , None ),
225+ ('day' , None , '2024-01-01' , None , None ),
226+ ('day' , '2024-01-02' , None , None , None ),
227+ ('day' , None , None , None , None ),
228+ ('invalid' , '2024-01-01' , '2024-01-02' , 'Invalid aggregate_period: invalid' , None ),
229229 (
230230 'day' ,
231231 'invalid' , '2024-01-02' ,
232- 'Invalid dates. You must provide a valid date_from and date_to formated as YYYY-MM-DD'
232+ 'Date has wrong format. Use one of these formats instead: YYYY-MM-DD.' ,
233+ 'date_from'
233234 ),
234235 (
235236 'day' ,
236237 '2024-01-01' ,
237238 'invalid' ,
238- 'Invalid dates. You must provide a valid date_from and date_to formated as YYYY-MM-DD'
239+ 'Date has wrong format. Use one of these formats instead: YYYY-MM-DD.' ,
240+ 'date_to'
239241 ),
240- ('day' , '2024-01-03' , '2024-01-02' , None ),
242+ ('day' , '2024-01-03' , '2024-01-02' , None , None ),
241243 )
242244 @ddt .unpack
243245 def test_load_query_params (
244- self , aggregate_period , date_from , date_to , error_message , mock_construct_result ,
246+ self , aggregate_period , date_from , date_to , error_message , error_date_field , mock_construct_result
245247 ): # pylint: disable=too-many-arguments
246248 """Verify that _load_query_params works as expected"""
247249 mock_construct_result .return_value = {
@@ -268,7 +270,10 @@ def test_load_query_params(
268270 response = self .client .get (url )
269271 if error_message :
270272 self .assertEqual (response .status_code , http_status .HTTP_400_BAD_REQUEST )
271- self .assertEqual (str (response .data ['detail' ]), error_message )
273+ if error_date_field :
274+ self .assertEqual (str (response .data [error_date_field ][0 ]), error_message )
275+ else :
276+ self .assertEqual (str (response .data ['detail' ]), error_message )
272277 else :
273278 self .assertEqual (response .status_code , http_status .HTTP_200_OK )
274279
0 commit comments