1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-10 00:34:16 +00:00

adding unittests

This commit is contained in:
deadc0de6
2017-03-15 18:00:54 +01:00
parent a1c48de359
commit bf7b3652a4
4 changed files with 246 additions and 0 deletions

53
tests/test_config.py Normal file
View File

@@ -0,0 +1,53 @@
"""
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()