1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-06 15:27:59 +00:00

refactoring

This commit is contained in:
deadc0de6
2018-10-08 18:13:13 +02:00
parent c0cb08c226
commit f6db3d3866
5 changed files with 86 additions and 78 deletions

View File

@@ -10,8 +10,8 @@ import os
import yaml
from dotdrop.config import Cfg
from dotdrop.dotdrop import importer
from dotdrop.dotdrop import compare
from dotdrop.dotdrop import cmd_importer
from dotdrop.dotdrop import cmd_compare
from dotdrop.dotfile import Dotfile
from dotdrop.installer import Installer
from dotdrop.comparator import Comparator
@@ -103,7 +103,7 @@ class TestCompare(unittest.TestCase):
dfiles = [d1, d2, d3, d4, d5]
# import the files
importer(opts, conf, dfiles)
cmd_importer(opts, conf, dfiles)
conf, opts = load_config(confpath, profile)
# compare the files
@@ -138,10 +138,10 @@ class TestCompare(unittest.TestCase):
self.assertTrue(results == expected)
# test compare from dotdrop
self.assertFalse(compare(opts, conf, tmp))
self.assertFalse(cmd_compare(opts, conf, tmp))
# test focus
self.assertFalse(compare(opts, conf, tmp, focus=d4))
self.assertFalse(compare(opts, conf, tmp, focus='/tmp/fake'))
self.assertFalse(cmd_compare(opts, conf, tmp, focus=d4))
self.assertFalse(cmd_compare(opts, conf, tmp, focus='/tmp/fake'))
def main():

View File

@@ -9,11 +9,11 @@ import unittest
import os
import yaml
from dotdrop.dotdrop import importer
from dotdrop.dotdrop import list_profiles
from dotdrop.dotdrop import list_files
from dotdrop.dotdrop import header
from dotdrop.dotdrop import update
from dotdrop.dotdrop import cmd_importer
from dotdrop.dotdrop import cmd_list_profiles
from dotdrop.dotdrop import cmd_list_files
from dotdrop.dotdrop import _header
from dotdrop.dotdrop import cmd_update
from dotdrop.config import Cfg
from tests.helpers import *
@@ -107,11 +107,11 @@ class TestImport(unittest.TestCase):
# import the dotfiles
dfiles = [dotfile1, dotfile2, dotfile3, dotfile4, dotfile5]
importer(opts, conf, dfiles)
cmd_importer(opts, conf, dfiles)
# import symlink
opts[Cfg.key_dotfiles_link] = True
sfiles = [dotfile6, dotfile7]
importer(opts, conf, sfiles)
cmd_importer(opts, conf, sfiles)
opts[Cfg.key_dotfiles_link] = False
# reload the config
@@ -193,15 +193,15 @@ class TestImport(unittest.TestCase):
self.assertTrue(os.path.islink(dotfile7))
self.assertTrue(os.path.realpath(dotfile7) == indt7)
list_profiles(conf)
list_files(opts, conf)
header()
cmd_list_profiles(conf)
cmd_list_files(opts, conf)
_header()
# fake test update
editcontent = 'edited'
edit_content(dotfile1, editcontent)
opts['safe'] = False
update(opts, conf, [dotfile1])
cmd_update(opts, conf, [dotfile1])
c2 = open(indt1, 'r').read()
self.assertTrue(editcontent == c2)

View File

@@ -9,9 +9,9 @@ import filecmp
from tests.helpers import *
from dotdrop.dotfile import Dotfile
from dotdrop.dotdrop import install
from dotdrop.installer import Installer
from dotdrop.action import Action
from dotdrop.dotdrop import cmd_install
class TestInstall(unittest.TestCase):
@@ -176,7 +176,7 @@ exec bspwm
opts['debug'] = True
opts['showdiff'] = True
opts['variables'] = {}
install(opts, conf)
cmd_install(opts, conf)
# now compare the generated files
self.assertTrue(os.path.exists(dst1))

View File

@@ -10,8 +10,8 @@ import os
import yaml
from dotdrop.config import Cfg
from dotdrop.dotdrop import importer
from dotdrop.dotdrop import update
from dotdrop.dotdrop import cmd_update
from dotdrop.dotdrop import cmd_importer
from dotdrop.dotfile import Dotfile
from tests.helpers import *
@@ -68,7 +68,7 @@ class TestUpdate(unittest.TestCase):
dfiles = [d1, dir1]
# import the files
importer(opts, conf, dfiles)
cmd_importer(opts, conf, dfiles)
conf, opts = load_config(confpath, profile)
# edit the files
@@ -86,7 +86,7 @@ class TestUpdate(unittest.TestCase):
# update it
opts['safe'] = False
opts['debug'] = True
update(opts, conf, [d1, dir1])
cmd_update(opts, conf, [d1, dir1])
# test content
newcontent = open(d1, 'r').read()