import json
import tempfile
import unittest
from pathlib import Path

from kraken_bot.config import load_config


class ConfigTests(unittest.TestCase):
    def test_config_rejects_duplicate_symbols(self) -> None:
        with tempfile.TemporaryDirectory() as tmp:
            path = Path(tmp) / "config.json"
            path.write_text(
                json.dumps(
                    {
                        "pairs": [
                            {"symbol": "XBTUSD", "strategy": "sma_crossover"},
                            {"symbol": "XBTUSD", "strategy": "rsi_mean_reversion"},
                        ]
                    }
                ),
                encoding="utf-8",
            )
            with self.assertRaisesRegex(ValueError, "configured more than once"):
                load_config(path)


if __name__ == "__main__":
    unittest.main()
