Added unit tests.
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
codecov
|
codecov
|
||||||
mock
|
mock
|
||||||
|
six
|
||||||
|
|||||||
22
tests.py
22
tests.py
@@ -1,15 +1,13 @@
|
|||||||
"""Installer unit tests."""
|
"""Installer unit tests."""
|
||||||
|
|
||||||
try:
|
|
||||||
import configparser
|
|
||||||
except ImportError:
|
|
||||||
import ConfigParser as configparser
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from six import StringIO
|
||||||
|
from six.moves import configparser
|
||||||
try:
|
try:
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -77,6 +75,22 @@ class ConfigFileTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
config.get("letsencrypt", "email"), "admin@example.test")
|
config.get("letsencrypt", "email"), "admin@example.test")
|
||||||
|
|
||||||
|
@patch("modoboa_installer.utils.user_input")
|
||||||
|
def test_configfile_loading(self, mock_user_input):
|
||||||
|
"""Check interactive mode."""
|
||||||
|
mock_user_input.side_effect = ["no"]
|
||||||
|
out = StringIO()
|
||||||
|
sys.stdout = out
|
||||||
|
run.main([
|
||||||
|
"--configfile", self.cfgfile,
|
||||||
|
"example.test"])
|
||||||
|
self.assertTrue(os.path.exists(self.cfgfile))
|
||||||
|
self.assertIn(
|
||||||
|
"modoboa automx amavis clamav dovecot nginx razor postfix"
|
||||||
|
" spamassassin uwsgi",
|
||||||
|
out.getvalue()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user