From d28eb94281b201b51251faa79ef95a79ddaabc88 Mon Sep 17 00:00:00 2001 From: phot0n Date: Wed, 11 May 2022 01:15:20 +0530 Subject: [PATCH] test: test for force install-app Note: this is a very minimal test, as frappe_docs doesn;t really have any doctypes --- frappe/tests/test_commands.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/frappe/tests/test_commands.py b/frappe/tests/test_commands.py index 67de6c6e41..18f18bc704 100644 --- a/frappe/tests/test_commands.py +++ b/frappe/tests/test_commands.py @@ -460,6 +460,36 @@ class TestCommands(BaseTestCommands): archive_directory = os.path.join(bench_path, f"archived/sites/{site}") self.assertTrue(os.path.exists(archive_directory)) + @skipIf( + not ( + frappe.conf.root_password and frappe.conf.admin_password and frappe.conf.db_type == "mariadb" + ), + "DB Root password and Admin password not set in config", + ) + def test_force_install_app(self): + if not os.path.exists(os.path.join(get_bench_path(), f"sites/{TEST_SITE}")): + self.execute( + f"bench new-site {TEST_SITE} --verbose " + f"--admin-password {frappe.conf.admin_password} " + f"--mariadb-root-password {frappe.conf.root_password} " + f"--db-type {frappe.conf.db_type or 'mariadb'} " + ) + + app_name = "frappe" + + # set admin password in site_config as when frappe force installs, we don't have the conf + self.execute(f"bench --site {TEST_SITE} set-config admin_password {frappe.conf.admin_password}") + + # try installing the frappe_docs app again on test site + self.execute(f"bench --site {TEST_SITE} install-app {app_name}") + self.assertIn(f"{app_name} already installed", self.stdout) + self.assertEqual(self.returncode, 0) + + # force install frappe_docs app on the test site + self.execute(f"bench --site {TEST_SITE} install-app {app_name} --force") + self.assertIn(f"Installing {app_name}", self.stdout) + self.assertEqual(self.returncode, 0) + class TestBackups(BaseTestCommands): backup_map = {