Skip to content
Snippets Groups Projects
Commit 7db0bc2f authored by Henke's avatar Henke
Browse files

Add tests for template creation and solve issue #7

parent 948d1419
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -8,7 +8,7 @@ class TemplateError(Exception): ...@@ -8,7 +8,7 @@ class TemplateError(Exception):
def _GetTemplateFolder(): def _GetTemplateFolder():
'''Returns the path to the template folder inside kattcmd.''' '''Returns the path to the template folder inside kattcmd.'''
my_dir = os.path.basename(__file__) my_dir = os.path.dirname(__file__)
path = os.path.join(my_dir, 'default_templates') path = os.path.join(my_dir, 'default_templates')
return path return path
...@@ -71,7 +71,7 @@ def AddCppTemplate(bus, folder, default=True): ...@@ -71,7 +71,7 @@ def AddCppTemplate(bus, folder, default=True):
topic='kattcmd:template:cpp-added', topic='kattcmd:template:cpp-added',
folder=folder, folder=folder,
default=default, default=default,
defaultname='cpp.py', defaultname='cpp.cpp',
fileending='.cpp' fileending='.cpp'
) )
......
import os
from .util import with_custom_home, CallChecker
from kattcmd import core
from kattcmd import bus as busmodule
from kattcmd.commands import init, template
def do_template_test_with_type(topic, listen_topic):
assert core.TouchStructure()
checker = CallChecker()
bus = busmodule.Bus()
init.Init(bus)
template.Init(bus)
bus.listen('kattcmd:init:directory-created', checker)
home = os.environ['HOME']
bus.call('kattcmd:init', bus, folder=home)
assert checker.yay
checker = CallChecker()
bus.listen(listen_topic, checker)
target = os.path.join(home, 'kattis', 'hello')
os.mkdir(target)
bus.call(topic, bus, target)
assert checker.yay
assert os.listdir(target)
@with_custom_home
def test_cpp_template():
do_template_test_with_type('kattcmd:template:cpp',
'kattcmd:template:cpp-added')
@with_custom_home
def test_py_template():
do_template_test_with_type('kattcmd:template:python',
'kattcmd:template:python-added')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment