Commit 583e91b1 authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

fix bundles_remove bug

parent a2c6dc73
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -810,7 +810,8 @@ def bundles_remove(
            keep_bundles[active_bundle_name] = active_bundle_url
    config.bundles = keep_bundles
    config.write()
    bundles_list()
    _sync_max_instance(directory, verbose=False)
    bundles_list(directory)


@app.command(help=_("Ajoute un fichier ou un dossier XML"))
@@ -1012,6 +1013,13 @@ def cache_clear():
    shutil.rmtree(Path(USER_MAX_DIR, "max"), ignore_errors=True)


@app.command(help=_("Affiche la version de climax"))
def version():
    import climax

    print(climax.__version__)


if os.environ.get("CLIMAX_DEBUG") == "True":

    @app.command(help=_("Planter Climax"))
+86 −3
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ from pathlib import Path
import tempfile
import subprocess


TEST_CONFIG_FILE = "tests_assets/max_config.xml"
TEST_CONFIG_EMPTY_FILE = "tests_assets/empty_max_config.xml"
TEST_CONFIG_FILE_BAD_ROOT = "tests_assets/bad_root_max_config.xml"
@@ -56,10 +57,92 @@ class TestConfigFiles(unittest.TestCase):
            self.assertTrue(Path(tmpdir, ".max").is_dir())
            p = subprocess.run(["climax", "projects"], stdout=subprocess.PIPE)
            self.assertTrue(tmpdir in p.stdout.decode("utf-8"))
            p = subprocess.run(
                ["climax", "info", "--directory", tmpdir], stdout=subprocess.PIPE
            # p = subprocess.run(
            #    ["climax", "info", "--directory", tmpdir], stdout=subprocess.PIPE
            # )
            # print(p.stdout.decode("utf-8"))

    def test_bundles_add_remove(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            max_test_dir = Path(tmpdir).resolve()

            # make new max instance and test default bundles
            subprocess.run(["climax", "new", tmpdir], stdout=subprocess.PIPE)
            self.assertTrue(
                Path(max_test_dir, ".max/basex/webapp/max/bundles/max-dev").exists()
            )
            self.assertTrue(
                Path(
                    max_test_dir, ".max/basex/webapp/max/bundles/max-dumb-xml"
                ).exists()
            )
            self.assertTrue(
                Path(max_test_dir, ".max/basex/webapp/max/bundles/max-export").exists()
            )

            # remove all bundles
            subprocess.run(
                ["climax", "bundles-remove", "max-dev", "--directory", max_test_dir],
                stdout=subprocess.PIPE,
            )
            self.assertTrue(
                Path(
                    max_test_dir, ".max/basex/webapp/max/bundles/max-dev/.ignore"
                ).exists()
            )
            subprocess.run(
                [
                    "climax",
                    "bundles-remove",
                    "max-dumb-xml",
                    "--directory",
                    max_test_dir,
                ],
                stdout=subprocess.PIPE,
            )
            self.assertTrue(
                Path(
                    max_test_dir, ".max/basex/webapp/max/bundles/max-dumb-xml/.ignore"
                ).exists()
            )
            subprocess.run(
                ["climax", "bundles-remove", "max-export", "--directory", max_test_dir],
                stdout=subprocess.PIPE,
            )
            self.assertTrue(
                Path(
                    max_test_dir, ".max/basex/webapp/max/bundles/max-export/.ignore"
                ).exists()
            )

            # add previously removed bundles
            subprocess.run(
                ["climax", "bundles-add", "max-dev", "--directory", max_test_dir],
                stdout=subprocess.PIPE,
            )
            self.assertFalse(
                Path(
                    max_test_dir, ".max/basex/webapp/max/bundles/max-dev/.ignore"
                ).exists()
            )
            subprocess.run(
                ["climax", "bundles-add", "max-dumb-xml", "--directory", max_test_dir],
                stdout=subprocess.PIPE,
            )
            self.assertFalse(
                Path(
                    max_test_dir, ".max/basex/webapp/max/bundles/max-dumb-xml/.ignore"
                ).exists()
            )
            subprocess.run(
                ["climax", "bundles-add", "max-export", "--directory", max_test_dir],
                stdout=subprocess.PIPE,
            )
            self.assertFalse(
                Path(
                    max_test_dir, ".max/basex/webapp/max/bundles/max-export/.ignore"
                ).exists()
            )
            print(p.stdout.decode("utf-8"))


if __name__ == "__main__":