Updated tests

This commit is contained in:
Spitap
2023-03-12 00:50:34 +01:00
parent 6261066ccd
commit 4cd3937fdd
2 changed files with 8 additions and 10 deletions

View File

@@ -354,7 +354,7 @@ def update_config(path, apply_update=True):
dropped_sections = list(set(old_sections) - set(new_sections)) dropped_sections = list(set(old_sections) - set(new_sections))
added_sections = list(set(new_sections) - set(old_sections)) added_sections = list(set(new_sections) - set(old_sections))
if len(dropped_sections) > 0 and not apply_update: if len(dropped_sections) > 0 and apply_update:
printcolor("Following section(s) will not be ported " printcolor("Following section(s) will not be ported "
"due to being deleted or renamed: " + "due to being deleted or renamed: " +
', '.join(dropped_sections), ', '.join(dropped_sections),
@@ -369,8 +369,8 @@ def update_config(path, apply_update=True):
old_options = config.options(section) old_options = config.options(section)
dropped_options = list(set(old_options) - set(new_options)) dropped_options = list(set(old_options) - set(new_options))
added_options = list(set(new_options) - set(old_sections)) added_options = list(set(new_options) - set(old_options))
if len(dropped_options) > 0 and not apply_update: if len(dropped_options) > 0 and apply_update:
printcolor(f"Following option(s) from section: {section}, " printcolor(f"Following option(s) from section: {section}, "
"will not be ported due to being " "will not be ported due to being "
"deleted or renamed: " + "deleted or renamed: " +

View File

@@ -18,6 +18,7 @@ try:
except ImportError: except ImportError:
from mock import patch from mock import patch
from modoboa_installer import utils
import run import run
@@ -81,15 +82,9 @@ class ConfigFileTestCase(unittest.TestCase):
[dummy] [dummy]
weird_old_option = "hey weird_old_option = "hey
""") """)
print("here")
print(os.path.isfile(cfgfile_temp))
out = StringIO() out = StringIO()
sys.stdout = out sys.stdout = out
run.main([ utils.update_config(cfgfile_temp)
"--update-configfile",
"--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"))
@@ -128,6 +123,9 @@ class ConfigFileTestCase(unittest.TestCase):
" postwhite spamassassin uwsgi", " postwhite spamassassin uwsgi",
out.getvalue() out.getvalue()
) )
self.assertNotIn("It seems that your config file is outdated.",
out.getvalue()
)
@patch("modoboa_installer.utils.user_input") @patch("modoboa_installer.utils.user_input")
def test_upgrade_mode(self, mock_user_input): def test_upgrade_mode(self, mock_user_input):