1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 12:46:44 +00:00
Files
dotdrop/tests/test_config.py
2017-03-15 18:00:54 +01:00

54 lines
1.4 KiB
Python

"""
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 = True
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.CONFIG_DOTPATH)
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()