@@ -1014,20 +1014,29 @@ def test_update_global_changelog(mocker, mock_release_init_request_file):
10141014
10151015
10161016def test_update_version_for_library_success_gapic (mocker ):
1017+ mock_content = '__version__ = "1.2.2"'
1018+ mock_json_metadata = {"clientLibrary" : {"version" : "0.1.0" }}
1019+ mock_shutil_copy = mocker .patch ("shutil.copy" )
1020+
10171021 m = mock_open ()
10181022
10191023 mock_rglob = mocker .patch ("pathlib.Path.rglob" )
10201024 mock_rglob .side_effect = [
10211025 [pathlib .Path ("repo/gapic_version.py" )], # 1st call (gapic_version.py)
1022- [], # 2nd call (version.py)
1026+ [pathlib . Path ( "repo/types/version.py" ) ], # 2nd call (types/ version.py).
10231027 [pathlib .Path ("repo/samples/snippet_metadata.json" )], # 3rd call (snippets)
10241028 ]
1025- mock_shutil_copy = mocker .patch ("shutil.copy" )
1026- mock_content = '__version__ = "1.2.2"'
1027- mock_json_metadata = {"clientLibrary" : {"version" : "0.1.0" }}
1029+ mock_rglob = mocker .patch ("cli._read_text_file" )
1030+ mock_rglob .side_effect = [
1031+ mock_content , # 1st call (gapic_version.py)
1032+ # Do not process version files in the `types` directory as some
1033+ # GAPIC libraries have `version.py` which are generated from
1034+ # `version.proto` and do not include SDK versions.
1035+ # Leave the content as empty because it doesn't contain version information
1036+ "" , # 2nd call (types/version.py)
1037+ ]
10281038
10291039 with unittest .mock .patch ("cli.open" , m ):
1030- mocker .patch ("cli._read_text_file" , return_value = mock_content )
10311040 mocker .patch ("cli._read_json_file" , return_value = mock_json_metadata )
10321041 _update_version_for_library (
10331042 "repo" , "output" , "packages/google-cloud-language" , "1.2.3"
0 commit comments