summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJuergen Ryannel <juergen.bocklage-ryannel@pelagicore.com>2016-12-12 14:06:41 +0100
committerJuergen Ryannel <juergen.bocklage-ryannel@pelagicore.com>2016-12-12 14:06:41 +0100
commit3811d7a9057444e3e122e9c2abc6e5a1323d0106 (patch)
tree5b5109c3b97dd94329c6fd38a62f64ed6309cbb4 /tests
parent75b88483c36869caac0da8459c219f87c09791bd (diff)
downloadqtivi-qface-3811d7a9057444e3e122e9c2abc6e5a1323d0106.tar.gz
added generator write test case
Diffstat (limited to 'tests')
-rw-r--r--tests/templates/module.txt1
-rw-r--r--tests/test_generator.py29
2 files changed, 24 insertions, 6 deletions
diff --git a/tests/templates/module.txt b/tests/templates/module.txt
new file mode 100644
index 0000000..d2ea91c
--- /dev/null
+++ b/tests/templates/module.txt
@@ -0,0 +1 @@
+{{module}} \ No newline at end of file
diff --git a/tests/test_generator.py b/tests/test_generator.py
index 83041b9..a6981b9 100644
--- a/tests/test_generator.py
+++ b/tests/test_generator.py
@@ -1,7 +1,7 @@
from qface.generator import FileSystem, Generator
import logging
import logging.config
-from pathlib import Path
+from path import Path
# logging.config.fileConfig('logging.ini')
logging.basicConfig()
@@ -9,7 +9,7 @@ logging.basicConfig()
log = logging.getLogger(__name__)
inputPath = Path('tests/in')
-log.debug('input path folder: {0}'.format(inputPath.absolute()))
+log.debug('input path folder: {0}'.format(inputPath.abspath()))
def loadSystem():
@@ -45,15 +45,32 @@ def test_parse_document():
def test_parse_document_list():
- input = [inputPath / 'com.pelagicore.ivi.tuner.qdl', inputPath / 'com.pelagicore.ivi.climate.qdl']
- system = FileSystem.parse(input)
+ src = [inputPath / 'com.pelagicore.ivi.tuner.qdl', inputPath / 'com.pelagicore.ivi.climate.qdl']
+ system = FileSystem.parse(src)
assert system.lookup('com.pelagicore.ivi.tuner')
assert system.lookup('com.pelagicore.ivi.climate')
def test_parse_document_mixed():
- input = [inputPath, inputPath / 'com.pelagicore.ivi.climate.qdl']
- system = FileSystem.parse(input)
+ src = [inputPath, inputPath / 'com.pelagicore.ivi.climate.qdl']
+ system = FileSystem.parse(src)
assert system.lookup('com.pelagicore.ivi.tuner')
assert system.lookup('com.pelagicore.ivi.climate')
assert system.lookup('com.pelagicore.one')
+
+
+def test_destination_prefix():
+
+ system = FileSystem.parse(inputPath)
+ out = Path('tests/out')
+ out.rmtree_p()
+ out.makedirs_p()
+ generator = Generator(searchpath='tests/templates')
+ for module in system.modules:
+ dst_template = '{{out}}/{{module|lower}}.txt'
+ ctx = {'out': out.abspath(), 'module': module}
+ generator.write(dst_template, 'module.txt', ctx)
+ path = generator.apply(dst_template, ctx)
+ assert Path(path).exists()
+
+ # out.rmtree_p()