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

more tests

This commit is contained in:
deadc0de6
2023-09-17 21:28:14 +02:00
committed by deadc0de
parent 45c3fbc3b8
commit d513cf9c36

View File

@@ -10,15 +10,48 @@ basic unittest for misc stuff
import unittest
from unittest.mock import patch
from jinja2 import TemplateNotFound
from dotdrop.profile import Profile
from dotdrop.linktypes import LinkTypes
from dotdrop.action import Cmd, Transform
from dotdrop.templategen import Templategen
from dotdrop.exceptions import UndefinedException
from jinja2 import TemplateNotFound
from tests.helpers import create_random_file, \
get_tempdir, clean
class TestActions(unittest.TestCase):
"""test case"""
def test_cmd(self):
"""test action"""
badstring = '{{@@ non-existing-var @@}}'
cmd = Cmd('key', badstring)
tmpl = Templategen()
self.assertFalse(cmd._get_action(tmpl, False))
cmd.args = [badstring]
self.assertFalse(cmd._get_args(tmpl))
def test_args(self):
"""test arg parameters"""
cmd = Cmd('key', '{0} {1}')
cmd.args = ['arg1']
self.assertFalse(cmd.execute())
cmd = Cmd('key', '{0}')
cmd.args = ['arg1', 'arg2']
self.assertFalse(cmd.execute())
def test_trans(self):
"""test trans"""
trans = Transform('key', 'value')
tmpdir = get_tempdir()
self.addCleanup(clean, tmpdir)
path, _ = create_random_file(tmpdir)
self.assertFalse(trans.transform('', path))
class TestTemplateGen(unittest.TestCase):
"""test case"""