@@ -653,6 +653,32 @@ def test_update_corpus_failure(self):
653653 )
654654 e .match ("Failed in RagCorpus update due to" )
655655
656+ @pytest .mark .usefixtures ("rag_data_client_mock" )
657+ @pytest .mark .parametrize ("corpus_name" , ["Capital-Corpus" , "123-Corpus" ])
658+ def test_get_corpus_with_valid_resource_name_success (self , corpus_name ):
659+ # Tests regex allowing names starting with uppercase or digits.
660+ rag_corpus = rag .get_corpus (corpus_name )
661+ rag_corpus_eq (rag_corpus , test_rag_constants .TEST_RAG_CORPUS )
662+
663+ @pytest .mark .usefixtures ("rag_data_client_mock" )
664+ @pytest .mark .parametrize ("file_name" , ["Capital-File" , "123-File" ])
665+ def test_get_file_with_valid_resource_name_success (self , file_name ):
666+ # This test covers the regex change for RAG file names.
667+ rag_file = rag .get_file (
668+ name = file_name ,
669+ corpus_name = test_rag_constants .TEST_RAG_CORPUS_ID ,
670+ )
671+ rag_file_eq (rag_file , test_rag_constants .TEST_RAG_FILE )
672+
673+ def test_get_corpus_with_invalid_name_format_failure (self ):
674+ # Verify names starting with invalid characters (like underscore) still fail.
675+ with pytest .raises (ValueError ) as e :
676+ rag .get_corpus ("_invalid-name" )
677+ e .match (
678+ "name must be of the format `projects/{project}/locations/{location}/"
679+ "ragCorpora/{rag_corpus}` or `{rag_corpus}`"
680+ )
681+
656682 @pytest .mark .usefixtures ("rag_data_client_mock" )
657683 def test_get_corpus_success (self ):
658684 rag_corpus = rag .get_corpus (test_rag_constants .TEST_RAG_CORPUS_RESOURCE_NAME )
0 commit comments