@@ -312,6 +312,7 @@ def test_handle_configure_no_new_library(mocker):
312312 with pytest .raises (ValueError , match = "Configuring a new library failed." ):
313313 handle_configure ()
314314
315+
315316def test_create_new_changelog_for_library (mocker ):
316317 """Tests that the changelog files are created correctly."""
317318 library_id = "google-cloud-language"
@@ -325,7 +326,9 @@ def test_create_new_changelog_for_library(mocker):
325326 docs_changelog_path = f"{ output } /packages/{ library_id } /docs/CHANGELOG.md"
326327
327328 # Check that makedirs was called for both parent directories
328- mock_makedirs .assert_any_call (os .path .dirname (package_changelog_path ), exist_ok = True )
329+ mock_makedirs .assert_any_call (
330+ os .path .dirname (package_changelog_path ), exist_ok = True
331+ )
329332 mock_makedirs .assert_any_call (os .path .dirname (docs_changelog_path ), exist_ok = True )
330333 assert mock_makedirs .call_count == 2
331334
@@ -1141,29 +1144,34 @@ def test_get_previous_version_failure(mock_state_file):
11411144 _get_previous_version ("google-cloud-does-not-exist" , LIBRARIAN_DIR )
11421145
11431146
1144- def test_update_changelog_for_library_success (mocker ):
1145- m = mock_open ()
1146-
1147+ def test_update_changelog_for_library_writes_both_changelogs (mocker ):
1148+ """Tests that _update_changelog_for_library writes to both changelogs."""
11471149 mock_content = """# Changelog
11481150
11491151[PyPI History][1]
11501152
11511153[1]: https://pypi.org/project/google-cloud-language/#history
1152-
1153- ## [2.17.2](https://github.com/googleapis/google-cloud-python/compare/google-cloud-language-v2.17.1...google-cloud-language-v2.17.2) (2025-06-11)
1154-
11551154"""
1156- with unittest .mock .patch ("cli.open" , m ):
1157- mocker .patch ("cli._read_text_file" , return_value = mock_content )
1158- _update_changelog_for_library (
1159- "repo" ,
1160- "output" ,
1161- _MOCK_LIBRARY_CHANGES ,
1162- "1.2.3" ,
1163- "1.2.2" ,
1164- "google-cloud-language" ,
1165- "CHANGELOG.md" ,
1166- )
1155+ mock_read = mocker .patch ("cli._read_text_file" , return_value = mock_content )
1156+ mock_write = mocker .patch ("cli._write_text_file" )
1157+ mock_path_exists = mocker .patch ("cli.os.path.lexists" , return_value = True )
1158+ _update_changelog_for_library (
1159+ "repo" ,
1160+ "output" ,
1161+ _MOCK_LIBRARY_CHANGES ,
1162+ "1.2.3" ,
1163+ "1.2.2" ,
1164+ "google-cloud-language" ,
1165+ "packages/google-cloud-language/CHANGELOG.md" ,
1166+ )
1167+
1168+ assert mock_write .call_count == 2
1169+ mock_write .assert_any_call (
1170+ "output/packages/google-cloud-language/CHANGELOG.md" , mocker .ANY
1171+ )
1172+ mock_write .assert_any_call (
1173+ "output/packages/google-cloud-language/docs/CHANGELOG.md" , mocker .ANY
1174+ )
11671175
11681176
11691177def test_process_changelog_success ():
0 commit comments