import inspect
from juris_base.tiers.tier4_daemon import BaseBrowserDaemon


class ConcreteDaemon(BaseBrowserDaemon):
    KEEPALIVE_URL = "https://example.gov.ar"
    PORT = 19999

    async def _do_search(self, page, params: dict) -> dict:
        return {"total": 0, "results": []}

    async def _do_get(self, page, id: str) -> dict:
        return {"id": id, "texto": ""}


def test_daemon_can_be_instantiated():
    daemon = ConcreteDaemon()
    assert daemon.PORT == 19999
    assert daemon.KEEPALIVE_URL == "https://example.gov.ar"


def test_daemon_has_required_abstract_methods():
    abstract = {
        name for name, method in inspect.getmembers(BaseBrowserDaemon)
        if getattr(method, "__isabstractmethod__", False)
    }
    assert "_do_search" in abstract
    assert "_do_get" in abstract
