from __future__ import annotations

import pytest

from finops_batches.application.registry import BatchRegistry


def test_registry_lists_registered_jobs() -> None:
    registry = BatchRegistry()
    registry.register("job.a", lambda: object())  # type: ignore[arg-type]
    registry.register("job.b", lambda: object())  # type: ignore[arg-type]

    assert registry.list_keys() == ["job.a", "job.b"]


def test_registry_rejects_duplicate_key() -> None:
    registry = BatchRegistry()
    registry.register("job.a", lambda: object())  # type: ignore[arg-type]

    with pytest.raises(ValueError):
        registry.register(
            "job.a",
            lambda: object(),  # type: ignore[arg-type]
        )
