diff options
author | minimumserious <commande.romain@gmail.com> | 2013-06-13 00:16:26 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-06-20 01:40:14 +0200 |
commit | e3e654a2686d195bcad4ca2723bf31936af2d270 (patch) | |
tree | 359f4d50ef9b53e5956b2ab753f2fac1558802e6 /tests/alchemyapp | |
parent | f21612942888b3a2290ee6b4468b6934090fe7af (diff) | |
download | factory-boy-e3e654a2686d195bcad4ca2723bf31936af2d270.tar factory-boy-e3e654a2686d195bcad4ca2723bf31936af2d270.tar.gz |
Added some tests for SQLAlchemyModelFactory
Diffstat (limited to 'tests/alchemyapp')
-rw-r--r-- | tests/alchemyapp/__init__.py | 0 | ||||
-rw-r--r-- | tests/alchemyapp/models.py | 47 |
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/alchemyapp/__init__.py b/tests/alchemyapp/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/alchemyapp/__init__.py diff --git a/tests/alchemyapp/models.py b/tests/alchemyapp/models.py new file mode 100644 index 0000000..e0193d4 --- /dev/null +++ b/tests/alchemyapp/models.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2013 Romain Commandé +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + + +"""Helpers for testing SQLAlchemy apps.""" + +from sqlalchemy import Column, Integer, Unicode, create_engine +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import scoped_session, sessionmaker + +session = scoped_session(sessionmaker()) +engine = create_engine('sqlite://') +session.configure(bind=engine) +Base = declarative_base() + + +class StandardModel(Base): + __tablename__ = 'StandardModelTable' + + id = Column(Integer(), primary_key=True) + foo = Column(Unicode(20)) + + +class NonIntegerPk(Base): + __tablename__ = 'NonIntegerPk' + + id = Column(Unicode(20), primary_key=True) + +Base.metadata.create_all(engine) |