# 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: 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]


import json
from flask import url_for
from .factories import ReleaseFactory
from matl_online.public.models import Release

        url = url_for('public.share', data='data')

        response = testapp.post(url, expect_errors=True)

        assert csrf.call_count == 1
        assert post.call_count == 1

        assert response.status_code == 400
        assert response.json.get('success') is False


class TestHome:
    """Test the main page of the site."""

    def test_defaults(self, testapp, mocker, db):
        """Check the default arguments passed to template."""
        url = url_for('public.home')
        ReleaseFactory.create_batch(size=10)

        render = mocker.patch('matl_online.public.views.render_template')
        render.return_value = ''

        testapp.get(url)

        args, params = render.call_args

        assert args[0] == 'index.html'
        assert params.get('inputs') == ''
        assert params.get('code') == ''

# 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: 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/test_views.py
import json
from flask import url_for
from .factories import ReleaseFactory
from matl_online.public.models import Release


        url = url_for('public.share', data='data')

        response = testapp.post(url, expect_errors=True)

        assert csrf.call_count == 1
        assert post.call_count == 1

        assert response.status_code == 400
        assert response.json.get('success') is False


class TestHome:
    """Test the main page of the site."""

    def test_defaults(self, testapp, mocker, db):
        """Check the default arguments passed to template."""
        url = url_for('public.home')
        ReleaseFactory.create_batch(size=10)

        render = mocker.patch('matl_online.public.views.render_template')
        render.return_value = ''

        testapp.get(url)

        args, params = render.call_args

        assert args[0] == 'index.html'
        assert params.get('inputs') == ''
        assert params.get('code') == ''

        assert params.get('version') == Release.latest().tag