@@ -266,3 +266,66 @@ def test_init_command_shows_description_when_use_help_option(
266
266
267
267
out , _ = capsys .readouterr ()
268
268
file_regression .check (out , extension = ".txt" )
269
+
270
+
271
+ def test_init_configuration_settings (tmpdir , mocker : MockFixture , config ):
272
+ """Test that all configuration settings are properly initialized."""
273
+ mocker .patch (
274
+ "questionary.select" ,
275
+ side_effect = [
276
+ FakeQuestion ("pyproject.toml" ),
277
+ FakeQuestion ("cz_conventional_commits" ),
278
+ FakeQuestion ("commitizen" ),
279
+ FakeQuestion ("semver" ),
280
+ ],
281
+ )
282
+ mocker .patch ("questionary.confirm" , return_value = FakeQuestion (True ))
283
+ mocker .patch ("questionary.text" , return_value = FakeQuestion ("$version" ))
284
+ mocker .patch ("questionary.checkbox" , return_value = FakeQuestion (None ))
285
+
286
+ with tmpdir .as_cwd ():
287
+ commands .Init (config )()
288
+
289
+ with open ("pyproject.toml" , encoding = "utf-8" ) as toml_file :
290
+ config_data = toml_file .read ()
291
+
292
+ # Verify all expected settings are present
293
+ assert 'name = "cz_conventional_commits"' in config_data
294
+ assert 'tag_format = "$version"' in config_data
295
+ assert 'version_scheme = "semver"' in config_data
296
+ assert 'version = "0.0.1"' in config_data
297
+ assert "update_changelog_on_bump = true" in config_data
298
+ assert "major_version_zero = true" in config_data
299
+
300
+
301
+ def test_init_configuration_with_version_provider (tmpdir , mocker : MockFixture , config ):
302
+ """Test configuration initialization with a different version provider."""
303
+ mocker .patch (
304
+ "questionary.select" ,
305
+ side_effect = [
306
+ FakeQuestion ("pyproject.toml" ),
307
+ FakeQuestion ("cz_conventional_commits" ),
308
+ FakeQuestion ("pep621" ), # Different version provider
309
+ FakeQuestion ("semver" ),
310
+ ],
311
+ )
312
+ mocker .patch ("questionary.confirm" , return_value = FakeQuestion (True ))
313
+ mocker .patch ("questionary.text" , return_value = FakeQuestion ("$version" ))
314
+ mocker .patch ("questionary.checkbox" , return_value = FakeQuestion (None ))
315
+
316
+ with tmpdir .as_cwd ():
317
+ commands .Init (config )()
318
+
319
+ with open ("pyproject.toml" , encoding = "utf-8" ) as toml_file :
320
+ config_data = toml_file .read ()
321
+
322
+ # Verify version provider is set instead of version
323
+ assert 'name = "cz_conventional_commits"' in config_data
324
+ assert 'tag_format = "$version"' in config_data
325
+ assert 'version_scheme = "semver"' in config_data
326
+ assert 'version_provider = "pep621"' in config_data
327
+ assert "update_changelog_on_bump = true" in config_data
328
+ assert "major_version_zero = true" in config_data
329
+ assert (
330
+ "version = " not in config_data
331
+ ) # Version should not be set when using version_provider
0 commit comments