Better test
This commit is contained in:
7
run.py
7
run.py
@@ -203,9 +203,10 @@ def main(input_args):
|
|||||||
"Would you like to update it? (Y/n) ")
|
"Would you like to update it? (Y/n) ")
|
||||||
if answer.lower().startswith("y"):
|
if answer.lower().startswith("y"):
|
||||||
config_file_update_complete(utils.update_config(args.configfile))
|
config_file_update_complete(utils.update_config(args.configfile))
|
||||||
answer = utils.user_input("Would you like to stop to review the updated config? (Y/n)")
|
if not args.stop_after_configfile_check:
|
||||||
if answer.lower().startswith("y"):
|
answer = utils.user_input("Would you like to stop to review the updated config? (Y/n)")
|
||||||
return
|
if answer.lower().startswith("y"):
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
utils.error("You might encounter unexpected errors ! "
|
utils.error("You might encounter unexpected errors ! "
|
||||||
"Make sur to update your config before opening an issue!")
|
"Make sur to update your config before opening an issue!")
|
||||||
|
|||||||
13
tests.py
13
tests.py
@@ -18,7 +18,6 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
|
||||||
from modoboa_installer import utils
|
|
||||||
import run
|
import run
|
||||||
|
|
||||||
|
|
||||||
@@ -63,7 +62,8 @@ class ConfigFileTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(config.get("certificate", "type"), "self-signed")
|
self.assertEqual(config.get("certificate", "type"), "self-signed")
|
||||||
self.assertEqual(config.get("database", "engine"), "postgres")
|
self.assertEqual(config.get("database", "engine"), "postgres")
|
||||||
|
|
||||||
def test_updating_configfile(self):
|
@patch("modoboa_installer.utils.user_input")
|
||||||
|
def test_updating_configfile(self, mock_user_input):
|
||||||
"""Check configfile update mechanism."""
|
"""Check configfile update mechanism."""
|
||||||
cfgfile_temp = os.path.join(self.workdir, "installer_old.cfg")
|
cfgfile_temp = os.path.join(self.workdir, "installer_old.cfg")
|
||||||
|
|
||||||
@@ -82,11 +82,18 @@ class ConfigFileTestCase(unittest.TestCase):
|
|||||||
[dummy]
|
[dummy]
|
||||||
weird_old_option = "hey
|
weird_old_option = "hey
|
||||||
""")
|
""")
|
||||||
|
mock_user_input.side_effect = ["y"]
|
||||||
out = StringIO()
|
out = StringIO()
|
||||||
sys.stdout = out
|
sys.stdout = out
|
||||||
utils.update_config(cfgfile_temp)
|
run.main([
|
||||||
|
"--stop-after-configfile-check",
|
||||||
|
"--configfile", cfgfile_temp,
|
||||||
|
"example.test"])
|
||||||
self.assertIn("dummy", out.getvalue())
|
self.assertIn("dummy", out.getvalue())
|
||||||
self.assertTrue(Path(self.workdir).glob("*.old"))
|
self.assertTrue(Path(self.workdir).glob("*.old"))
|
||||||
|
self.assertIn("Update complete",
|
||||||
|
out.getvalue()
|
||||||
|
)
|
||||||
|
|
||||||
@patch("modoboa_installer.utils.user_input")
|
@patch("modoboa_installer.utils.user_input")
|
||||||
def test_interactive_mode_letsencrypt(self, mock_user_input):
|
def test_interactive_mode_letsencrypt(self, mock_user_input):
|
||||||
|
|||||||
Reference in New Issue
Block a user