aboutsummaryrefslogtreecommitdiff
path: root/ihatemoney/tests/tests.py
diff options
context:
space:
mode:
author0livd <0livd@users.noreply.github.com>2017-07-09 22:29:57 +0200
committerAlexis Metaireau <alexis@notmyidea.org>2017-07-09 22:29:57 +0200
commit8fd53f827e6678485214d1073a1256737ebf8ce5 (patch)
treef396d70e9f86e70dfa8e26fcc55c63e9542f7f75 /ihatemoney/tests/tests.py
parent3a4282fd75e3b3317b2b08b4aa2e6ac154310e73 (diff)
downloadihatemoney-mirror-8fd53f827e6678485214d1073a1256737ebf8ce5.zip
ihatemoney-mirror-8fd53f827e6678485214d1073a1256737ebf8ce5.tar.gz
ihatemoney-mirror-8fd53f827e6678485214d1073a1256737ebf8ce5.tar.bz2
Revert configuration tests deletion (#250)
Some supernatural power erased the configuration tests, they're now back !
Diffstat (limited to 'ihatemoney/tests/tests.py')
-rw-r--r--ihatemoney/tests/tests.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/ihatemoney/tests/tests.py b/ihatemoney/tests/tests.py
index 271477a..cb92756 100644
--- a/ihatemoney/tests/tests.py
+++ b/ihatemoney/tests/tests.py
@@ -14,13 +14,12 @@ from werkzeug.security import generate_password_hash
from flask import session
from flask_testing import TestCase
-from ihatemoney.run import create_app, db
+from ihatemoney.run import create_app, db, load_configuration
from ihatemoney import models
from ihatemoney import utils
# Unset configuration file env var if previously set
-if 'IHATEMONEY_SETTINGS_FILE_PATH' in os.environ:
- del os.environ['IHATEMONEY_SETTINGS_FILE_PATH']
+os.environ.pop('IHATEMONEY_SETTINGS_FILE_PATH', None)
__HERE__ = os.path.dirname(os.path.abspath(__file__))
@@ -73,7 +72,7 @@ class IhatemoneyTestCase(BaseTestCase):
WTF_CSRF_ENABLED = False # Simplifies the tests.
-class DefaultConfigurationTestCase(BaseTestCase):
+class ConfigurationTestCase(BaseTestCase):
def test_default_configuration(self):
"""Test that default settings are loaded when no other configuration file is specified"""
@@ -83,6 +82,29 @@ class DefaultConfigurationTestCase(BaseTestCase):
self.assertEqual(self.app.config['MAIL_DEFAULT_SENDER'],
("Budget manager", "budget@notmyidea.org"))
+ def test_env_var_configuration_file(self):
+ """Test that settings are loaded from the specified configuration file"""
+ os.environ['IHATEMONEY_SETTINGS_FILE_PATH'] = os.path.join(__HERE__,
+ "ihatemoney_envvar.cfg")
+ load_configuration(self.app)
+ self.assertEqual(self.app.config['SECRET_KEY'], 'lalatra')
+
+ # Test that the specified configuration file is loaded
+ # even if the default configuration file ihatemoney.cfg exists
+ os.environ['IHATEMONEY_SETTINGS_FILE_PATH'] = os.path.join(__HERE__,
+ "ihatemoney_envvar.cfg")
+ self.app.config.root_path = __HERE__
+ load_configuration(self.app)
+ self.assertEqual(self.app.config['SECRET_KEY'], 'lalatra')
+
+ os.environ.pop('IHATEMONEY_SETTINGS_FILE_PATH', None)
+
+ def test_default_configuration_file(self):
+ """Test that settings are loaded from the default configuration file"""
+ self.app.config.root_path = __HERE__
+ load_configuration(self.app)
+ self.assertEqual(self.app.config['SECRET_KEY'], 'supersecret')
+
class BudgetTestCase(IhatemoneyTestCase):