Skip to content

Commit

Permalink
pivot workdir in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deadc0de6 committed Oct 24, 2024
1 parent 8c42e74 commit 86f685c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ def fake_config(path, dotfiles, profile,
return path


def get_workdir():
"""get the workdir"""
workdir = '~/.config/dotdrop'
workdir = os.path.expanduser(workdir)
workdir = os.path.normpath(workdir)
return workdir


class TestInstall(unittest.TestCase):
"""test case"""

Expand Down Expand Up @@ -353,6 +361,11 @@ def test_install_import_configs(self):

def test_link_children(self):
"""test the link children"""
# create workdir
work_dir = get_tempdir()
self.assertTrue(os.path.exists(work_dir))
self.addCleanup(clean, work_dir)

# create source dir
src_dir = get_tempdir()
self.assertTrue(os.path.exists(src_dir))
Expand All @@ -366,7 +379,7 @@ def test_link_children(self):
# create 3 random files in source
srcs = [create_random_file(src_dir)[0] for _ in range(3)]

installer = Installer()
installer = Installer(workdir=work_dir)
installer.install(templater=MagicMock(), src=src_dir,
dst=dst_dir, linktype=LinkTypes.LINK_CHILDREN,
actionexec=None)
Expand Down Expand Up @@ -479,6 +492,11 @@ def test_prompts_to_replace_dst(self):

def test_runs_templater(self):
"""test runs templater"""
# create workdir
work_dir = get_tempdir()
self.assertTrue(os.path.exists(work_dir))
self.addCleanup(clean, work_dir)

# create source dir
src_dir = get_tempdir()
self.assertTrue(os.path.exists(src_dir))
Expand All @@ -493,7 +511,7 @@ def test_runs_templater(self):
srcs = [create_random_file(src_dir)[0] for _ in range(3)]

# setup installer and mocks
installer = Installer()
installer = Installer(workdir=work_dir)
templater = MagicMock()
templater.generate.return_value = b'content'

Expand Down

0 comments on commit 86f685c

Please sign in to comment.