# Path: suma/web/resources.py
# class LinkResource(ResourceWrapper):
# 
#     def __getitem__(self, key):
#         raise KeyError(key)
# 
# Path: suma/core/models/link.py
# class Link(Base, TimestampColumns):
#     hashid = Column(String, index=True, unique=True, nullable=False)
#     _url = Column('url', Unicode, index=True, nullable=False)
#     user_id = Column(BigInteger)
#     _hash = Column('hash', String, index=True, nullable=False)
#     _hash_netloc = Column('hash_netloc', String, nullable=False)
#     _hash_path = Column('hash_path', String, nullable=False)
#     meta = Column(MutableDict.as_mutable(JSONB), default={})
#     __table_args__ = (
#         Index('unique_url_and_user_id', _url, user_id, unique=True,
#               postgresql_where=(user_id != None)),
#         Index('unique_url_and_user_id_is_null', 'url', unique=True,
#               postgresql_where=(user_id == None))
#     )
# 
#     is_banned = column_property(
#         exists().where(
#             or_(
#                 BlockedLink.hash.in_([_hash, _hash_netloc, _hash_path])
#             )
#         )
#     )
# 
#     @property
#     def clicks(self):
#         if self._clicks:
#             return self._clicks.counter
#         return 0
#     
#     @hybrid_property
#     def url(self):
#         return self._url
# 
#     @url.setter
#     def url(self, value):
#         self._url = value
#         self._hash, self._hash_netloc, self._hash_path = create_url_hashes(value)
# 
# Path: suma/core/services/interfaces/file.py
# class IFileService(Interface):
# 
#     def create(self, data, filename, folder):
#         pass
# 
#     def url(self, filename):
#         pass
# 
# Path: suma/core/services/interfaces/task.py
# class ITaskService(Interface):
#     def add_click(self, link_id, ip=None, referer=None):
#         pass
# 
#     def get_link_data(self, link_id):
#         pass


from suma.web.resources import LinkResource
from suma.core.models import Link
from suma.core.services.interfaces import ITaskService, IFileService
from zope.interface import implementer
    from suma.web.views import LinkView
import pytest
import os

    def get_link_data(self, link_id):
        pass

@pytest.fixture
def link(db_session):
    link = Link(hashid='1234', url='http://google.com')
    db_session.add(link)
    db_session.flush()
    return link

@pytest.fixture
def link_resource(link):
    return LinkResource(link)

@pytest.fixture
def fake_task_service(config):
    service = FakeTaskService()
    config.register_service(service, name='task')
    return service

@pytest.fixture
def fake_file_service(config):
    service = FakeFileService()
    config.register_service(service, name='file')
    return service


@pytest.fixture(autouse=True)
def routes(config):

# Path: suma/web/resources.py
# class LinkResource(ResourceWrapper):
# 
#     def __getitem__(self, key):
#         raise KeyError(key)
# 
# Path: suma/core/models/link.py
# class Link(Base, TimestampColumns):
#     hashid = Column(String, index=True, unique=True, nullable=False)
#     _url = Column('url', Unicode, index=True, nullable=False)
#     user_id = Column(BigInteger)
#     _hash = Column('hash', String, index=True, nullable=False)
#     _hash_netloc = Column('hash_netloc', String, nullable=False)
#     _hash_path = Column('hash_path', String, nullable=False)
#     meta = Column(MutableDict.as_mutable(JSONB), default={})
#     __table_args__ = (
#         Index('unique_url_and_user_id', _url, user_id, unique=True,
#               postgresql_where=(user_id != None)),
#         Index('unique_url_and_user_id_is_null', 'url', unique=True,
#               postgresql_where=(user_id == None))
#     )
# 
#     is_banned = column_property(
#         exists().where(
#             or_(
#                 BlockedLink.hash.in_([_hash, _hash_netloc, _hash_path])
#             )
#         )
#     )
# 
#     @property
#     def clicks(self):
#         if self._clicks:
#             return self._clicks.counter
#         return 0
#     
#     @hybrid_property
#     def url(self):
#         return self._url
# 
#     @url.setter
#     def url(self, value):
#         self._url = value
#         self._hash, self._hash_netloc, self._hash_path = create_url_hashes(value)
# 
# Path: suma/core/services/interfaces/file.py
# class IFileService(Interface):
# 
#     def create(self, data, filename, folder):
#         pass
# 
#     def url(self, filename):
#         pass
# 
# Path: suma/core/services/interfaces/task.py
# class ITaskService(Interface):
#     def add_click(self, link_id, ip=None, referer=None):
#         pass
# 
#     def get_link_data(self, link_id):
#         pass


# Path: tests/web/views/test_web_link_views.py
from suma.web.resources import LinkResource
from suma.core.models import Link
from suma.core.services.interfaces import ITaskService, IFileService
from zope.interface import implementer
    from suma.web.views import LinkView
import pytest
import os


    def get_link_data(self, link_id):
        pass

@pytest.fixture
def link(db_session):
    link = Link(hashid='1234', url='http://google.com')
    db_session.add(link)
    db_session.flush()
    return link

@pytest.fixture
def link_resource(link):
    return LinkResource(link)

@pytest.fixture
def fake_task_service(config):
    service = FakeTaskService()
    config.register_service(service, name='task')
    return service

@pytest.fixture
def fake_file_service(config):
    service = FakeFileService()
    config.register_service(service, name='file')
    return service


@pytest.fixture(autouse=True)
def routes(config):

    config.include('suma.web.routes')