Repository :
http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
---------------------------------------------------------------
commit f53b20637e8417912a1804f3f4febe9c81f468c2
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Mon Dec 17 21:57:31 2012 +0100
Make the alembic_ini argument optional as we don't use it in the unit-tests
---------------------------------------------------------------
fedocal/fedocallib/model.py | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/fedocal/fedocallib/model.py b/fedocal/fedocallib/model.py
index 2c6283c..87510b0 100644
--- a/fedocal/fedocallib/model.py
+++ b/fedocal/fedocallib/model.py
@@ -42,7 +42,7 @@ from sqlalchemy.sql import and_
BASE = declarative_base()
-def create_tables(db_url, alembic_ini, debug=False):
+def create_tables(db_url, alembic_ini=None, debug=False):
""" Create the tables in the database using the information from the
url obtained.
@@ -50,7 +50,8 @@ def create_tables(db_url, alembic_ini, debug=False):
information with regards to the database engine, the host to connect
to, the user and password and the database name.
ie: <engine>://<user>:<password>@<host>/<dbname>
- :arg alembic_ini, path to the alembic ini file.
+ :kwarg alembic_ini, path to the alembic ini file. This is necessary to be
+ able to use alembic correctly, but not for the unit-tests.
:kwarg debug, a boolean specifying wether we should have the verbose
output of sqlalchemy or not.
:return a session that can be used to query the database.
@@ -58,12 +59,13 @@ def create_tables(db_url, alembic_ini, debug=False):
engine = create_engine(db_url, echo=debug)
BASE.metadata.create_all(engine)
- # then, load the Alembic configuration and generate the
- # version table, "stamping" it with the most recent rev:
- from alembic.config import Config
- from alembic import command
- alembic_cfg = Config(alembic_ini)
- command.stamp(alembic_cfg, "head")
+ if alembic_ini is not None:
+ # then, load the Alembic configuration and generate the
+ # version table, "stamping" it with the most recent rev:
+ from alembic.config import Config
+ from alembic import command
+ alembic_cfg = Config(alembic_ini)
+ command.stamp(alembic_cfg, "head")
sessionmak = sessionmaker(bind=engine)
return sessionmak()