Index: tests/test_utils.py |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/tests/test_utils.py |
@@ -0,0 +1,38 @@ |
+# This file is part of the Adblock Plus web scripts, |
+# Copyright (C) 2006-2017 eyeo GmbH |
+# |
+# Adblock Plus is free software: you can redistribute it and/or modify |
+# it under the terms of the GNU General Public License version 3 as |
+# published by the Free Software Foundation. |
+# |
+# Adblock Plus is distributed in the hope that it will be useful, |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+# GNU General Public License for more details. |
+# |
+# You should have received a copy of the GNU General Public License |
+# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
+ |
+import pytest |
+ |
+from sitescripts.utils import get_template |
+ |
+ |
+def test_get_template_default_path(): |
+ """Load template from inside sitescripts.""" |
Jon Sonesen
2017/04/03 07:42:41
Perhaps the docstring here should include the addi
Vasily Kuznetsov
2017/04/03 08:59:25
Thanks for bringing this up. Maybe we should say s
Jon Sonesen
2017/04/03 09:03:23
Well I brought this up because you mentioned that
Sebastian Noack
2017/04/03 09:51:43
I'm used to add leading/trailing new lines to docs
Vasily Kuznetsov
2017/04/03 10:25:15
Hm. Are you sure? I don't think I would suggest th
Vasily Kuznetsov
2017/04/03 10:25:15
PEP257 recommends that the summary in multiline do
|
+ template = get_template('__init__.py') |
+ assert template.render({}).startswith('# This file') |
+ |
+ |
+@pytest.mark.parametrize('mode', ['relative', 'absolute']) |
+def test_get_template(tmpdir, mode): |
+ """Load template using relative or absolute path.""" |
Jon Sonesen
2017/04/03 07:42:41
Same here?
|
+ template_path = tmpdir.join('template.tmpl') |
+ template_path.write('value = {{ value }}') |
+ |
+ if mode == 'absolute': |
+ template = get_template(template_path.strpath) |
+ else: |
+ template = get_template('template.tmpl', template_path=tmpdir.strpath) |
Jon Sonesen
2017/04/03 07:42:41
Does this work as relative since you provide the n
Vasily Kuznetsov
2017/04/03 08:59:25
It's considered relative because the first argumen
Jon Sonesen
2017/04/03 09:03:23
I see, thanks
|
+ |
+ assert template.render({'value': 1}) == 'value = 1' |