aboutsummaryrefslogtreecommitdiff
path: root/ihatemoney/tests/tests.py
diff options
context:
space:
mode:
authorJocelynDelalande <JocelynDelalande@users.noreply.github.com>2018-01-07 23:01:34 +0100
committerGitHub <noreply@github.com>2018-01-07 23:01:34 +0100
commit34a21616506402c764d481cc7a28e2b9818518f9 (patch)
treeb7b3079157c9c12976c0df7f329a341e843629b2 /ihatemoney/tests/tests.py
parent4ab8863eb20ea75fc0b3990471a01f4874735f3c (diff)
parentc24ee6f1c4e1c1090f0833f65b795512fc03de30 (diff)
downloadihatemoney-mirror-34a21616506402c764d481cc7a28e2b9818518f9.zip
ihatemoney-mirror-34a21616506402c764d481cc7a28e2b9818518f9.tar.gz
ihatemoney-mirror-34a21616506402c764d481cc7a28e2b9818518f9.tar.bz2
Merge pull request #308 from spiral-project/almet/fix-template-inclusion-packaging
Include all .j2 files in the packaged version.
Diffstat (limited to 'ihatemoney/tests/tests.py')
-rw-r--r--ihatemoney/tests/tests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/ihatemoney/tests/tests.py b/ihatemoney/tests/tests.py
index de53c58..d4b6d7a 100644
--- a/ihatemoney/tests/tests.py
+++ b/ihatemoney/tests/tests.py
@@ -4,6 +4,10 @@ try:
import unittest2 as unittest
except ImportError:
import unittest # NOQA
+try:
+ from unittest.mock import patch
+except ImportError:
+ from mock import patch
import os
import json
@@ -16,6 +20,7 @@ from flask import session
from flask_testing import TestCase
from ihatemoney.run import create_app, db, load_configuration
+from ihatemoney.manage import GenerateConfig, GeneratePasswordHash
from ihatemoney import models
from ihatemoney import utils
@@ -1406,5 +1411,27 @@ class ServerTestCase(IhatemoneyTestCase):
self.assertStatus(200, req)
+class CommandTestCase(BaseTestCase):
+ def test_generate_config(self):
+ """ Simply checks that all config file generation
+ - raise no exception
+ - produce something non-empty
+ """
+ cmd = GenerateConfig()
+ for config_file in cmd.get_options()[0].kwargs['choices']:
+ with patch('sys.stdout', new=six.StringIO()) as stdout:
+ cmd.run(config_file)
+ print(stdout.getvalue())
+ self.assertNotEqual(len(stdout.getvalue().strip()), 0)
+
+ def test_generate_password_hash(self):
+ cmd = GeneratePasswordHash()
+ with patch('sys.stdout', new=six.StringIO()) as stdout, \
+ patch('getpass.getpass', new=lambda prompt: 'secret'): # NOQA
+ cmd.run()
+ print(stdout.getvalue())
+ self.assertEqual(len(stdout.getvalue().strip()), 187)
+
+
if __name__ == "__main__":
unittest.main()