# Path: matl_online/public/models.py
# class Release(Model):
#     """Model for storing metadata associated with MATL releases."""
# 
#     __tablename__ = 'releases'
# 
#     id = Column(db.Integer, primary_key=True)
#     tag = Column(db.String, unique=True, nullable=False)
#     date = Column(db.DateTime, unique=True, nullable=False)
# 
#     def __repr__(self):
#         """Create a custom string representation."""
#         return '<Release %r>' % self.tag
# 
#     @hybrid_property
#     def version(self):
#         """Convert release number to tuple for comparisons."""
#         return tuple(int(x) for x in self.tag.split('.'))
# 
#     @classmethod
#     def latest(cls):
#         """Get the latest release from Github."""
#         releases = cls.query.all()
#         if len(releases) == 0:
#             return None
# 
#         releases.sort(key=lambda x: x.version)
#         return releases[-1]
# 
# Path: tests/factories.py
# class ReleaseFactory(BaseFactory):
#     """Factory for creating Release objects on demand."""
# 
#     tag = Sequence(lambda n: '{0}.0.0'.format(n))
#     date = LazyFunction(datetime.now)
# 
#     class Meta:
#         """Meta information for the factory."""
# 
#         model = Release


import pytest
from datetime import datetime
from matl_online.public.models import Release
from .factories import ReleaseFactory
"""Unit tests for checking database models and behavior."""





@pytest.mark.usefixtures('db')
class TestRelease:
    """Series of tests for the Release database model."""

    def test_get_latest(self):
        """Make sure that the expected release is returned as the latest."""
        # Create 3 release each time checking that the latest is the latest
        # release
        for k in range(3):
            # Ensure that this is the latest release

# Path: matl_online/public/models.py
# class Release(Model):
#     """Model for storing metadata associated with MATL releases."""
# 
#     __tablename__ = 'releases'
# 
#     id = Column(db.Integer, primary_key=True)
#     tag = Column(db.String, unique=True, nullable=False)
#     date = Column(db.DateTime, unique=True, nullable=False)
# 
#     def __repr__(self):
#         """Create a custom string representation."""
#         return '<Release %r>' % self.tag
# 
#     @hybrid_property
#     def version(self):
#         """Convert release number to tuple for comparisons."""
#         return tuple(int(x) for x in self.tag.split('.'))
# 
#     @classmethod
#     def latest(cls):
#         """Get the latest release from Github."""
#         releases = cls.query.all()
#         if len(releases) == 0:
#             return None
# 
#         releases.sort(key=lambda x: x.version)
#         return releases[-1]
# 
# Path: tests/factories.py
# class ReleaseFactory(BaseFactory):
#     """Factory for creating Release objects on demand."""
# 
#     tag = Sequence(lambda n: '{0}.0.0'.format(n))
#     date = LazyFunction(datetime.now)
# 
#     class Meta:
#         """Meta information for the factory."""
# 
#         model = Release


# Path: tests/test_releases.py
import pytest
from datetime import datetime
from matl_online.public.models import Release
from .factories import ReleaseFactory

"""Unit tests for checking database models and behavior."""





@pytest.mark.usefixtures('db')
class TestRelease:
    """Series of tests for the Release database model."""

    def test_get_latest(self):
        """Make sure that the expected release is returned as the latest."""
        # Create 3 release each time checking that the latest is the latest
        # release
        for k in range(3):
            # Ensure that this is the latest release

            assert ReleaseFactory() == Release.latest()