@@ -447,7 +447,7 @@ def test_create_template(
447
447
project_id : str , location_id : str , template_id : str
448
448
) -> None :
449
449
template = create_model_armor_template (project_id , location_id , template_id )
450
- assert template is not None
450
+ assert template
451
451
452
452
453
453
def test_get_template (
@@ -509,17 +509,16 @@ def test_create_model_armor_template_with_basic_sdp(
509
509
f"projects/{ project_id } /locations/{ location_id } /templates/{ template_id } "
510
510
)
511
511
512
- assert (
513
- created_template .name == expected_name_format
514
- ), "Template name does not match the expected format."
512
+ assert created_template .name == expected_name_format
515
513
516
514
filter_enforcement = (
517
515
created_template .filter_config .sdp_settings .basic_config .filter_enforcement
518
516
)
519
517
520
518
assert (
521
- filter_enforcement .name == "ENABLED"
522
- ), f"Expected filter_enforcement to be ENABLED, but got { filter_enforcement } "
519
+ filter_enforcement .name
520
+ == modelarmor_v1 .SdpBasicConfig .filter_enforcement .ENABLED .name
521
+ )
523
522
524
523
525
524
def test_create_model_armor_template_with_advanced_sdp (
@@ -533,33 +532,27 @@ def test_create_model_armor_template_with_advanced_sdp(
533
532
that matches the expected format.
534
533
"""
535
534
536
- sdp_inspect_template_id , sdr_deidentify_template_id = sdp_templates
535
+ sdp_inspect_template_id , sdp_deidentify_template_id = sdp_templates
537
536
created_template = create_model_armor_template_with_advanced_sdp (
538
537
project_id ,
539
538
location_id ,
540
539
template_id ,
541
540
sdp_inspect_template_id ,
542
- sdr_deidentify_template_id ,
541
+ sdp_deidentify_template_id ,
543
542
)
544
543
545
544
expected_name_format = (
546
545
f"projects/{ project_id } /locations/{ location_id } /templates/{ template_id } "
547
546
)
548
547
549
- assert (
550
- created_template .name == expected_name_format
551
- ), "Template name does not match the expected format."
548
+ assert created_template .name == expected_name_format
552
549
553
550
advanced_config = (
554
551
created_template .filter_config .sdp_settings .advanced_config
555
552
)
556
- assert (
557
- advanced_config .inspect_template == sdp_inspect_template_id
558
- ), f"Expected inspect_template to be { sdp_inspect_template_id } , but got { advanced_config .inspect_template } "
553
+ assert advanced_config .inspect_template == sdp_inspect_template_id
559
554
560
- assert (
561
- advanced_config .deidentify_template == sdr_deidentify_template_id
562
- ), f"Expected deidentify_template to be { sdr_deidentify_template_id } , but got { advanced_config .deidentify_template } "
555
+ assert advanced_config .deidentify_template == sdp_deidentify_template_id
563
556
564
557
565
558
def test_create_model_armor_template_with_metadata (
@@ -578,9 +571,7 @@ def test_create_model_armor_template_with_metadata(
578
571
f"projects/{ project_id } /locations/{ location_id } /templates/{ template_id } "
579
572
)
580
573
581
- assert (
582
- created_template .name == expected_name_format
583
- ), "Template name does not match the expected format."
574
+ assert created_template .name == expected_name_format
584
575
assert created_template .template_metadata .ignore_partial_invocation_failures
585
576
assert created_template .template_metadata .log_sanitize_operations
586
577
@@ -601,18 +592,14 @@ def test_create_model_armor_template_with_labels(
601
592
f"projects/{ project_id } /locations/{ location_id } /templates/{ template_id } "
602
593
)
603
594
604
- assert (
605
- created_template .name == expected_name_format
606
- ), "Template name does not match the expected format."
595
+ assert created_template .name == expected_name_format
607
596
608
597
template_with_labels = get_model_armor_template (
609
598
project_id , location_id , template_id
610
599
)
611
600
612
601
for key , value in expected_labels .items ():
613
- assert (
614
- template_with_labels .labels .get (key ) == value
615
- ), f"Label { key } does not match. Expected: { value } , Got: { template_with_labels .labels .get (key )} "
602
+ assert template_with_labels .labels .get (key ) == value
616
603
617
604
618
605
def test_list_model_armor_templates_with_filter (
@@ -636,7 +623,7 @@ def test_list_model_armor_templates_with_filter(
636
623
637
624
assert any (
638
625
template .name == expected_template_name for template in templates
639
- ), "Template does not exist in the list"
626
+ )
640
627
641
628
642
629
def test_update_model_armor_template_metadata (
@@ -658,9 +645,7 @@ def test_update_model_armor_template_metadata(
658
645
f"projects/{ project_id } /locations/{ location_id } /templates/{ template_id } "
659
646
)
660
647
661
- assert (
662
- updated_template .name == expected_name_format
663
- ), "Template name does not match the expected format."
648
+ assert updated_template .name == expected_name_format
664
649
assert updated_template .template_metadata .ignore_partial_invocation_failures
665
650
assert updated_template .template_metadata .log_sanitize_operations
666
651
@@ -685,18 +670,14 @@ def test_update_model_armor_template_labels(
685
670
f"projects/{ project_id } /locations/{ location_id } /templates/{ template_id } "
686
671
)
687
672
688
- assert (
689
- updated_template .name == expected_name_format
690
- ), "Template name does not match the expected format."
673
+ assert updated_template .name == expected_name_format
691
674
692
675
template_with_lables = get_model_armor_template (
693
676
project_id , location_id , template_id
694
677
)
695
678
696
679
for key , value in expected_labels .items ():
697
- assert (
698
- template_with_lables .labels .get (key ) == value
699
- ), f"Label { key } does not match. Expected: { value } , Got: { template_with_lables .labels .get (key )} "
680
+ assert template_with_lables .labels .get (key ) == value
700
681
701
682
702
683
def test_update_model_armor_template_with_mask_configuration (
@@ -718,16 +699,15 @@ def test_update_model_armor_template_with_mask_configuration(
718
699
f"projects/{ project_id } /locations/{ location_id } /templates/{ template_id } "
719
700
)
720
701
721
- assert (
722
- updated_template .name == expected_name_format
723
- ), "Template name does not match the expected format."
702
+ assert updated_template .name == expected_name_format
724
703
725
704
filter_enforcement = (
726
705
updated_template .filter_config .sdp_settings .basic_config .filter_enforcement
727
706
)
728
707
assert (
729
- filter_enforcement .name != "ENABLED"
730
- ), f"Expected filter_enforcement not to be ENABLED, but got { filter_enforcement } "
708
+ filter_enforcement .name
709
+ != modelarmor_v1 .SdpBasicConfig .filter_enforcement .ENABLED .name
710
+ )
731
711
732
712
733
713
def test_sanitize_user_prompt_with_all_rai_filter_template (
0 commit comments