| 1 |
import os |
| 2 |
from ..cheetahsupport import TurboCheetah |
| 3 |
|
| 4 |
here = os.path.dirname(__file__) |
| 5 |
|
| 6 |
values = { |
| 7 |
'v': 'VV', |
| 8 |
'one': 1, |
| 9 |
} |
| 10 |
|
| 11 |
|
| 12 |
def test_normal(): |
| 13 |
plugin = TurboCheetah() |
| 14 |
|
| 15 |
s = plugin.render(values, template='turbocheetah.tests.simple1') |
| 16 |
assert s.strip() == 'This is a test: VV' |
| 17 |
|
| 18 |
s = plugin.render(values, template='turbocheetah.tests.import_inherit') |
| 19 |
assert s.strip() == 'Inherited: import' |
| 20 |
|
| 21 |
|
| 22 |
def test_path(): |
| 23 |
plugin = TurboCheetah() |
| 24 |
plugin.search_path = [here] |
| 25 |
|
| 26 |
s = plugin.render(values, template_file='simple1') |
| 27 |
assert s.strip() == 'This is a test: VV' |
| 28 |
|
| 29 |
s = plugin.render(values, template_file='sub/master') |
| 30 |
assert s.strip() == 'sub1: 1' |
| 31 |
|
| 32 |
|
| 33 |
def test_search(): |
| 34 |
plugin = TurboCheetah() |
| 35 |
plugin.search_path = [os.path.join(here, 'sub'), |
| 36 |
os.path.join(here, 'sub2'), |
| 37 |
here] |
| 38 |
|
| 39 |
s = plugin.render(values, template_file='simple1') |
| 40 |
assert s.strip() == 'This is a test: VV' |
| 41 |
|
| 42 |
s = plugin.render(values, template_file='master') |
| 43 |
assert s.strip() == 'sub1: 1' |
| 44 |
|
| 45 |
s = plugin.render(values, template_file='page') |
| 46 |
assert s.strip() == 'SUB: sub content' |
| 47 |
|
| 48 |
s = plugin.render(values, template_file='page_over') |
| 49 |
assert s.strip() == 'SUB: override content' |
| 50 |
|
| 51 |
|
| 52 |
s = plugin.render(values, template_file='page_template_over') |
| 53 |
assert s.strip() == 'OVER: sub content' |
| 54 |
|
| 55 |
plugin.search_path = [os.path.join(here, 'sub'), |
| 56 |
here] |
| 57 |
s = plugin.render(values, template_file='page_over') |
| 58 |
assert s.strip() == 'SUB: sub content' |
| 59 |
|
| 60 |
|
| 61 |
def test_string(): |
| 62 |
|
| 63 |
plugin = TurboCheetah() |
| 64 |
s = plugin.render(values, template_string="""Hey $v""") |
| 65 |
assert s == "Hey VV" |
| 66 |
|
| 67 |
plugin.search_path = [here] |
| 68 |
s = plugin.render(values, template_string="#extends inherit_from\ns value") |
| 69 |
assert s.strip() == 'inherit: s value' |