"""Module for a base asteex fixture."""

from abc import ABC, abstractmethod


class FixtureError(Exception):
    """Exception class for errors raised by fixtures."""


class Fixture(ABC):
    """Base class for a asteex fixture."""

    @abstractmethod
    def get_id(self):
        """Get the unique identifier of the fixture.

        :returns: string id.
        """

    @abstractmethod
    def get_dependencies(self):
        """Get names of the variables that must be present in the execution context.

        :returns: iterable with string names of the required fixtures.
        """

    @abstractmethod
    def evaluate(self, context, case):
        """Evaluate the fixture for the context and case.

        :param context: dictionary with values for the dependencies.
        :param case: test :class:`case <asteex.abstract.case.Case>`.
        :returns: async context manager for the fixture value.
            The manager may raise :class:`FixtureError` on entering and/or exiting.
        :raises: :class:`FixtureError`.
        """

    def __repr__(self):
        class_name = self.__class__.__name__
        fixture_id = self.get_id()

        return f"{class_name}(fixture_id='{fixture_id}')"
