From e830d9766bb002f68d385a71ed4a462d86aa0a80 Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Fri, 9 Feb 2018 17:09:18 +0200 Subject: [PATCH] Add new tests for configure() --- tests/pylorax/test_projects.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/pylorax/test_projects.py b/tests/pylorax/test_projects.py index ce9588ec..624faf32 100644 --- a/tests/pylorax/test_projects.py +++ b/tests/pylorax/test_projects.py @@ -166,3 +166,23 @@ class ProjectsTest(unittest.TestCase): print(modules) self.assertEqual(modules[0]["name"], "bash") self.assertEqual(modules[0]["dependencies"][0]["name"], "basesystem") + + +class ConfigureTest(unittest.TestCase): + @classmethod + def setUpClass(self): + self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.configure.") + self.conf_file = os.path.join(self.tmp_dir, 'test.conf') + open(self.conf_file, 'w').write("[composer]\ncache_dir = /tmp/cache-test") + + @classmethod + def tearDownClass(self): + shutil.rmtree(self.tmp_dir) + + def test_configure_reads_existing_file(self): + config = configure(conf_file=self.conf_file) + self.assertEqual(config.get('composer', 'cache_dir'), '/tmp/cache-test') + + def test_configure_reads_non_existing_file(self): + config = configure(conf_file=self.conf_file + '.non-existing') + self.assertEqual(config.get('composer', 'cache_dir'), '/var/tmp/composer/cache')