@@ -531,44 +531,41 @@ def test_single_filter_value_field_validation(mocker):
531
531
SingleFilterSchema ().dump (singleFilterObj )
532
532
533
533
534
- def test_single_filter_validation (mocker ):
535
- with pytest .raises (
536
- ValueError ,
537
- match = "key must be none for filter type {}" .format (
538
- SingleFilterBy .PROJECT_ID
539
- ),
540
- ):
541
- SingleFilter (
534
+ @pytest .mark .parametrize (
535
+ "by,key,op,value,err_msg" ,
536
+ [
537
+ [
542
538
SingleFilterBy .PROJECT_ID ,
543
539
"invalid_key" ,
544
540
SingleFilterOperator .EQUAL_TO ,
545
541
PROJECT_ID ,
546
- )
547
- with pytest .raises (
548
- ValueError ,
549
- match = "key must not be none for filter type {}" .format (
550
- SingleFilterBy .TAG
551
- ),
552
- ):
553
- SingleFilter (
542
+ "key must be none for filter type {}" .format (
543
+ SingleFilterBy .PROJECT_ID
544
+ ),
545
+ ],
546
+ [
554
547
SingleFilterBy .TAG ,
555
548
None ,
556
549
SingleFilterOperator .EQUAL_TO ,
557
550
"tag_value" ,
558
- )
559
- with pytest .raises (
560
- ValueError ,
561
- match = (
562
- "value can not be type {}. It has to be either an int "
563
- + "or a float"
564
- ).format (type ("param_value" )),
565
- ):
566
- SingleFilter (
551
+ "key must not be none for filter type {}" .format (
552
+ SingleFilterBy .TAG
553
+ ),
554
+ ],
555
+ [
567
556
SingleFilterBy .PARAM ,
568
557
"param_key" ,
569
558
SingleFilterOperator .GREATER_THAN ,
570
559
"param_value" ,
571
- )
560
+ "invalid type {}. Value has to be either an int or a float" .format (
561
+ type ("param_value" )
562
+ ),
563
+ ],
564
+ ],
565
+ )
566
+ def test_single_filter_validation (mocker , by , key , op , value , err_msg ):
567
+ with pytest .raises (ValueError , match = err_msg ):
568
+ SingleFilter (by , key , op , value )
572
569
573
570
574
571
def test_compound_filter_validation (mocker ):
0 commit comments