-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat!: change the code to support postgresql instead of sqlite * increase corpus name size * feat: automatically create PostgreSQL database when running manage.py db-create * fix: fix psycopg2-binary version * feat: use switch for DBMS-specific calls * fix: keep naming schema from SQLite development database * fix: adapt validation to new field size * fix: use dynamic list length instead of hard-coded value * fix: fix incorrect number of tokens in new corpus * feat: add separate PostgreSQL test config * refactor: use id attribute instead of hard-coded ID * feat: create test database if it doesn't exist * fix: PostgreSQL does not autoincrement if fixed id is given * fix: PostgreSQL's unique constraint message is different from SQLite's * fix: in PostgreSQL, all fields must be part of GROUP BY clause * ci: add PostgreSQL tests to CI * fix: close connection to PostgreSQL database in tearDown * fix: create database if it does not exist --------- Co-authored-by: François Ferry <[email protected]> Co-authored-by: Carine Dengler <[email protected]> Co-authored-by: Thibault Clérice <[email protected]>
- Loading branch information
1 parent
2b1b858
commit a2624cd
Showing
15 changed files
with
140 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,7 +195,6 @@ def add_default_users(): | |
:return: | ||
""" | ||
default_user = User( | ||
id=1, | ||
first_name="admin", | ||
last_name="admin", | ||
email="[email protected]", | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,8 +49,7 @@ class DevelopmentConfig(Config): | |
DEBUG = True | ||
ASSETS_DEBUG = True | ||
SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \ | ||
'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite') | ||
#SQLALCHEMY_DATABASE_URI = "postgres://postgres:[email protected]:5432/postgres" | ||
"postgresql://user:pwd@localhost:5432/data-dev" | ||
print('THIS APP IS IN DEBUG MODE. YOU SHOULD NOT SEE THIS IN PRODUCTION.') | ||
|
||
|
@@ -75,11 +74,10 @@ class DevelopmentConfig(Config): | |
BABEL_TRANSLATION_DIRECTORIES = os.path.join(os.path.dirname(__file__), "translations") | ||
|
||
|
||
class TestConfig(Config): | ||
class BaseTestConfig(Config): | ||
"""Test configuration base class.""" | ||
DEBUG = True | ||
ASSETS_DEBUG = True | ||
SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or \ | ||
'sqlite:///' + os.path.join(basedir, 'data-test.sqlite') | ||
print('THIS APP IS IN DEBUG MODE. YOU SHOULD NOT SEE THIS IN PRODUCTION.') | ||
|
||
# Disable CSRF for login purpose | ||
|
@@ -101,9 +99,18 @@ class TestConfig(Config): | |
EMAIL_SENDER = '{app_name} Admin <{email}>'.format(app_name=Config.APP_NAME, email=MAIL_USERNAME) | ||
|
||
|
||
class SQLiteTestConfig(BaseTestConfig): | ||
SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or \ | ||
'sqlite:///' + os.path.join(basedir, 'data-test.sqlite') | ||
|
||
|
||
class PostgreSQLTestConfig(BaseTestConfig): | ||
SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or \ | ||
'postgresql:///data-test' | ||
|
||
|
||
config = { | ||
"dev": DevelopmentConfig, | ||
"prod": Config, | ||
"test": TestConfig | ||
"test": PostgreSQLTestConfig if os.environ.get("TEST_DBMS", "sqlite").lower() == "postgresql" else SQLiteTestConfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.