feat[config]: Use toml for configs

This commit is contained in:
2026-06-27 22:44:25 +03:00
parent fd88aabe46
commit 28f1fda048
5 changed files with 42 additions and 42 deletions
+12 -11
View File
@@ -2,18 +2,18 @@ from tempfile import NamedTemporaryFile
import pytest
from src.config import Config, read_ini_config
from src.config import Config, read_toml_config
@pytest.mark.parametrize(
"config_data, expected",
[
(
"[main]\ntoken=something\n"
"format={owner}/{name}\n"
"ssh_key=/tmp/no_key\n"
"endpoint=https://example.com\n"
"out_dir=/home/user/repositories",
'[main]\ntoken = "something"\n'
'format = "{owner}/{name}"\n'
'ssh_key = "/tmp/no_key"\n'
'endpoint = "https://example.com"\n'
'out_dir = "/home/user/repositories"',
Config(
token="something",
repository_format="{owner}/{name}",
@@ -23,20 +23,21 @@ from src.config import Config, read_ini_config
),
),
("[main]", None),
("not valid toml", None),
],
)
def test_ini_config(config_data, expected):
def test_toml_config(config_data, expected):
with NamedTemporaryFile() as tf:
if config_data:
tf.write(config_data.encode("utf-8"))
tf.flush()
if expected:
assert read_ini_config(tf.name) == expected
assert read_toml_config(tf.name) == expected
else:
with pytest.raises(RuntimeError):
read_ini_config(tf.name)
read_toml_config(tf.name)
def test_ini_config_not_exists():
def test_toml_config_not_exists():
with pytest.raises(RuntimeError):
read_ini_config("not_existing_file")
read_toml_config("not_existing_file")