""" author: deadc0de6 (https://github.com/deadc0de6) Copyright (c) 2017, deadc0de6 basic unittest for the config parser """ import unittest import os import tempfile import shutil from dotdrop.config import Cfg from tests.helpers import * class TestConfig(unittest.TestCase): CONFIG_BACKUP = False CONFIG_CREATE = True CONFIG_DOTPATH = 'dotfiles' TMPSUFFIX = '.dotdrop' CONFIG_NAME = 'config.yaml' def test_config(self): '''Test the config class''' tmp = get_tempfolder() self.assertTrue(os.path.exists(tmp)) self.addCleanup(clean, tmp) confpath = create_fake_config(tmp, configname=self.CONFIG_NAME, dotpath=self.CONFIG_DOTPATH, backup=self.CONFIG_BACKUP, create=self.CONFIG_CREATE) conf = Cfg(confpath) self.assertTrue(conf is not None) opts = conf.get_configs() self.assertTrue(opts is not None) self.assertTrue(opts != {}) self.assertTrue(opts['backup'] == self.CONFIG_BACKUP) self.assertTrue(opts['create'] == self.CONFIG_CREATE) dotpath = os.path.join(tmp, self.CONFIG_DOTPATH) self.assertTrue(opts['dotpath'] == dotpath) self.assertTrue(conf._is_valid()) def main(): unittest.main() if __name__ == '__main__': main()