"""Base test cases for testing documents."""

from mtp.apps.common.tests.test_cases import MTPTestCase

from ..factories import DocumentFactory


class BaseDocumentTestCase:
    """Base test case to tests documents.

    It provides some default test data useful in a lot of tests.

    Attributes
    ----------
    document: ``mtp.apps.documents.models.Document`` instance.

    """

    @classmethod
    def setUpTestData(cls):
        """Create some data to use in documents tests."""

        super().setUpTestData()

        with cls.training.override_version_state(cls.training.VERSION_STATES.DRAFT):

            cls.document = DocumentFactory(training=cls.training)


class DocumentTestCase(BaseDocumentTestCase, MTPTestCase):
    """A test case based on ``BaseDocumentTestCase`` and ``MTPTestCase``.

    Should be used in most cases.

    """
