@@ -420,3 +420,66 @@ def test_init_with_valid_tag_selection(config, mocker: MockFixture, tmpdir):
420420 content = toml_file .read ()
421421 assert 'version = "0.9.0"' in content
422422 assert 'version_scheme = "semver"' in content
423+
424+
425+ def test_init_configuration_settings (tmpdir , mocker : MockFixture , config ):
426+ """Test that all configuration settings are properly initialized."""
427+ mocker .patch (
428+ "questionary.select" ,
429+ side_effect = [
430+ FakeQuestion ("pyproject.toml" ),
431+ FakeQuestion ("cz_conventional_commits" ),
432+ FakeQuestion ("commitizen" ),
433+ FakeQuestion ("semver" ),
434+ ],
435+ )
436+ mocker .patch ("questionary.confirm" , return_value = FakeQuestion (True ))
437+ mocker .patch ("questionary.text" , return_value = FakeQuestion ("$version" ))
438+ mocker .patch ("questionary.checkbox" , return_value = FakeQuestion (None ))
439+
440+ with tmpdir .as_cwd ():
441+ commands .Init (config )()
442+
443+ with open ("pyproject.toml" , encoding = "utf-8" ) as toml_file :
444+ config_data = toml_file .read ()
445+
446+ # Verify all expected settings are present
447+ assert 'name = "cz_conventional_commits"' in config_data
448+ assert 'tag_format = "$version"' in config_data
449+ assert 'version_scheme = "semver"' in config_data
450+ assert 'version = "0.0.1"' in config_data
451+ assert "update_changelog_on_bump = true" in config_data
452+ assert "major_version_zero = true" in config_data
453+
454+
455+ def test_init_configuration_with_version_provider (tmpdir , mocker : MockFixture , config ):
456+ """Test configuration initialization with a different version provider."""
457+ mocker .patch (
458+ "questionary.select" ,
459+ side_effect = [
460+ FakeQuestion ("pyproject.toml" ),
461+ FakeQuestion ("cz_conventional_commits" ),
462+ FakeQuestion ("pep621" ), # Different version provider
463+ FakeQuestion ("semver" ),
464+ ],
465+ )
466+ mocker .patch ("questionary.confirm" , return_value = FakeQuestion (True ))
467+ mocker .patch ("questionary.text" , return_value = FakeQuestion ("$version" ))
468+ mocker .patch ("questionary.checkbox" , return_value = FakeQuestion (None ))
469+
470+ with tmpdir .as_cwd ():
471+ commands .Init (config )()
472+
473+ with open ("pyproject.toml" , encoding = "utf-8" ) as toml_file :
474+ config_data = toml_file .read ()
475+
476+ # Verify version provider is set instead of version
477+ assert 'name = "cz_conventional_commits"' in config_data
478+ assert 'tag_format = "$version"' in config_data
479+ assert 'version_scheme = "semver"' in config_data
480+ assert 'version_provider = "pep621"' in config_data
481+ assert "update_changelog_on_bump = true" in config_data
482+ assert "major_version_zero = true" in config_data
483+ assert (
484+ "version = " not in config_data
485+ ) # Version should not be set when using version_provider
0 commit comments