****************************************** Tests how relationships are serialized. Based on a reported bug in `Github #57 <https://github.com/insightindustry/sqlathanor/issues/57>`_ """ # pylint: disable=line-too-long import pytest from sqlathanor import declarative_base, Column, relationship from sqlalchemy import create_engine, Integer, String, Sequence, ForeignKey from sqlalchemy.orm import sessionmaker Base = declarative_base() def serialize_address(input): raise RuntimeError('error was raised successfully!') class User(Base): __tablename__ = 'users' id = Column( Integer, Sequence('user_id_seq'), primary_key=True, supports_dict=True, )
TableConstructor.__http__ = [ 'GET', 'POST', 'PUT', 'DELETE', ] TableConstructor.__serialization__ = [ AttributeConfiguration(name='id', supports_json=(False, True)), AttributeConfiguration(name='api_user', supports_json=(False, True)), AttributeConfiguration(name='api_time', supports_json=(False, True)), ] TableConstructor.id = Column(Integer, primary_key=True) TableConstructor.api_user = Column(Unicode(256)) TableConstructor.api_time = Column(DateTime) DeclarativeBase = declarative_base(cls=TableConstructor) def get_tables_dict(*args): """ Load ApiModule.__module_depends__ & ApiModule.__table_dict__ and control module depends to error in ExceptionDepend """ #test depends tables_module = [ my.__module_name__ for my in DeclarativeBase.__subclasses__() ] for depend in args: if depend not in tables_module: raise ExceptionDepend("Depend Module '{}' not found".format(