import pytest

from debgpt.configurator import _edit_config_template


def test_edit_config_template():
    template = """
[section]
key1 = "value1"
    key2 = 42
key3 = true
"""
    # Edit string value
    res1 = _edit_config_template(template, "key1", '"new_value"')
    assert 'key1 = "new_value"' in res1
    assert "key2 = 42" in res1

    # Edit number with spaces
    res2 = _edit_config_template(template, "key2", "99")
    assert "key2 = 99" in res2

    # Edit boolean
    res3 = _edit_config_template(template, "key3", "false")
    assert "key3 = false" in res3

    # Key not found
    res4 = _edit_config_template(template, "key4", "10")
    assert "key4" not in res4
