Loading tests.py +28 −4 Original line number Diff line number Diff line import unittest import os from src.climax.__main__ import ( MaXProjectConfig, dir_is_max, Loading @@ -18,6 +19,7 @@ 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" TEST_MAX_PROJECT_DIR = "tests_assets/max_project_dir" TEST_CLIMAX_HOME = Path(tempfile.gettempdir(), "climax-tests-home") class TestConfigFiles(unittest.TestCase): Loading Loading @@ -59,12 +61,23 @@ class TestConfigFiles(unittest.TestCase): def test_max_project(self): with tempfile.TemporaryDirectory() as tmpdir: p = subprocess.run(["climax", "--help"], stdout=subprocess.PIPE) test_env = os.environ.copy() TEST_CLIMAX_HOME.mkdir(parents=True, exist_ok=True) test_env["CLIMAX_HOME"] = str(TEST_CLIMAX_HOME) p = subprocess.run( ["climax", "--help"], stdout=subprocess.PIPE, env=test_env ) self.assertTrue("--show-completion" in p.stdout.decode("utf-8")) p = subprocess.run(["climax", "new", tmpdir], stdout=subprocess.PIPE) p = subprocess.run( ["climax", "new", tmpdir], stdout=subprocess.PIPE, env=test_env ) self.assertTrue(Path(tmpdir, "config.xml").is_file()) self.assertTrue(Path(tmpdir, ".max").is_dir()) p = subprocess.run(["climax", "projects"], stdout=subprocess.PIPE) p = subprocess.run( ["climax", "projects", "--json-out"], stdout=subprocess.PIPE, env=test_env, ) self.assertTrue(tmpdir in p.stdout.decode("utf-8")) # p = subprocess.run( # ["climax", "info", "--directory", tmpdir], stdout=subprocess.PIPE Loading @@ -74,9 +87,14 @@ class TestConfigFiles(unittest.TestCase): def test_bundles_add_remove(self): with tempfile.TemporaryDirectory() as tmpdir: max_test_dir = Path(tmpdir).resolve() test_env = os.environ.copy() TEST_CLIMAX_HOME.mkdir(parents=True, exist_ok=True) test_env["CLIMAX_HOME"] = str(TEST_CLIMAX_HOME) # make new max instance and test default bundles subprocess.run(["climax", "new", tmpdir], stdout=subprocess.PIPE) subprocess.run( ["climax", "new", tmpdir], stdout=subprocess.PIPE, env=test_env ) self.assertTrue( Path(max_test_dir, ".max/basex/webapp/max/bundles/max-dev").exists() ) Loading @@ -93,6 +111,7 @@ class TestConfigFiles(unittest.TestCase): subprocess.run( ["climax", "bundles-remove", "max-dev", "--directory", max_test_dir], stdout=subprocess.PIPE, env=test_env, ) self.assertTrue( Path( Loading @@ -108,6 +127,7 @@ class TestConfigFiles(unittest.TestCase): max_test_dir, ], stdout=subprocess.PIPE, env=test_env, ) self.assertTrue( Path( Loading @@ -117,6 +137,7 @@ class TestConfigFiles(unittest.TestCase): subprocess.run( ["climax", "bundles-remove", "max-export", "--directory", max_test_dir], stdout=subprocess.PIPE, env=test_env, ) self.assertTrue( Path( Loading @@ -128,6 +149,7 @@ class TestConfigFiles(unittest.TestCase): subprocess.run( ["climax", "bundles-add", "max-dev", "--directory", max_test_dir], stdout=subprocess.PIPE, env=test_env, ) self.assertFalse( Path( Loading @@ -137,6 +159,7 @@ class TestConfigFiles(unittest.TestCase): subprocess.run( ["climax", "bundles-add", "max-dumb-xml", "--directory", max_test_dir], stdout=subprocess.PIPE, env=test_env, ) self.assertFalse( Path( Loading @@ -146,6 +169,7 @@ class TestConfigFiles(unittest.TestCase): subprocess.run( ["climax", "bundles-add", "max-export", "--directory", max_test_dir], stdout=subprocess.PIPE, env=test_env, ) self.assertFalse( Path( Loading Loading
tests.py +28 −4 Original line number Diff line number Diff line import unittest import os from src.climax.__main__ import ( MaXProjectConfig, dir_is_max, Loading @@ -18,6 +19,7 @@ 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" TEST_MAX_PROJECT_DIR = "tests_assets/max_project_dir" TEST_CLIMAX_HOME = Path(tempfile.gettempdir(), "climax-tests-home") class TestConfigFiles(unittest.TestCase): Loading Loading @@ -59,12 +61,23 @@ class TestConfigFiles(unittest.TestCase): def test_max_project(self): with tempfile.TemporaryDirectory() as tmpdir: p = subprocess.run(["climax", "--help"], stdout=subprocess.PIPE) test_env = os.environ.copy() TEST_CLIMAX_HOME.mkdir(parents=True, exist_ok=True) test_env["CLIMAX_HOME"] = str(TEST_CLIMAX_HOME) p = subprocess.run( ["climax", "--help"], stdout=subprocess.PIPE, env=test_env ) self.assertTrue("--show-completion" in p.stdout.decode("utf-8")) p = subprocess.run(["climax", "new", tmpdir], stdout=subprocess.PIPE) p = subprocess.run( ["climax", "new", tmpdir], stdout=subprocess.PIPE, env=test_env ) self.assertTrue(Path(tmpdir, "config.xml").is_file()) self.assertTrue(Path(tmpdir, ".max").is_dir()) p = subprocess.run(["climax", "projects"], stdout=subprocess.PIPE) p = subprocess.run( ["climax", "projects", "--json-out"], stdout=subprocess.PIPE, env=test_env, ) self.assertTrue(tmpdir in p.stdout.decode("utf-8")) # p = subprocess.run( # ["climax", "info", "--directory", tmpdir], stdout=subprocess.PIPE Loading @@ -74,9 +87,14 @@ class TestConfigFiles(unittest.TestCase): def test_bundles_add_remove(self): with tempfile.TemporaryDirectory() as tmpdir: max_test_dir = Path(tmpdir).resolve() test_env = os.environ.copy() TEST_CLIMAX_HOME.mkdir(parents=True, exist_ok=True) test_env["CLIMAX_HOME"] = str(TEST_CLIMAX_HOME) # make new max instance and test default bundles subprocess.run(["climax", "new", tmpdir], stdout=subprocess.PIPE) subprocess.run( ["climax", "new", tmpdir], stdout=subprocess.PIPE, env=test_env ) self.assertTrue( Path(max_test_dir, ".max/basex/webapp/max/bundles/max-dev").exists() ) Loading @@ -93,6 +111,7 @@ class TestConfigFiles(unittest.TestCase): subprocess.run( ["climax", "bundles-remove", "max-dev", "--directory", max_test_dir], stdout=subprocess.PIPE, env=test_env, ) self.assertTrue( Path( Loading @@ -108,6 +127,7 @@ class TestConfigFiles(unittest.TestCase): max_test_dir, ], stdout=subprocess.PIPE, env=test_env, ) self.assertTrue( Path( Loading @@ -117,6 +137,7 @@ class TestConfigFiles(unittest.TestCase): subprocess.run( ["climax", "bundles-remove", "max-export", "--directory", max_test_dir], stdout=subprocess.PIPE, env=test_env, ) self.assertTrue( Path( Loading @@ -128,6 +149,7 @@ class TestConfigFiles(unittest.TestCase): subprocess.run( ["climax", "bundles-add", "max-dev", "--directory", max_test_dir], stdout=subprocess.PIPE, env=test_env, ) self.assertFalse( Path( Loading @@ -137,6 +159,7 @@ class TestConfigFiles(unittest.TestCase): subprocess.run( ["climax", "bundles-add", "max-dumb-xml", "--directory", max_test_dir], stdout=subprocess.PIPE, env=test_env, ) self.assertFalse( Path( Loading @@ -146,6 +169,7 @@ class TestConfigFiles(unittest.TestCase): subprocess.run( ["climax", "bundles-add", "max-export", "--directory", max_test_dir], stdout=subprocess.PIPE, env=test_env, ) self.assertFalse( Path( Loading