-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Old people: | ||
|
||
Bill | ||
|
||
Bob | ||
|
||
|
||
Third person is Mark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"people":[ | ||
{"name": "Bill", "age": 100}, | ||
{"name": "Bob", "age": 90}, | ||
{"name": "Mark", "age": 25} | ||
], | ||
"hello": "World!" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Old people: | ||
#foreach ($person in $people) | ||
#if($person.age > 70) | ||
$person.name | ||
#end | ||
#end | ||
|
||
Third person is $people[2].name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
|
||
from nose.tools import eq_ | ||
from moban.plugins import ENGINES, BaseEngine | ||
from moban_velocity.engine import EngineVelocity | ||
|
||
|
||
def test_velocity_engine_type(): | ||
engine = ENGINES.get_engine("velocity", [], "") | ||
assert engine.engine_cls == EngineVelocity | ||
pass | ||
|
||
|
||
def test_velocity_file_test(): | ||
output = "test.txt" | ||
path = os.path.join("tests", "fixtures", "velocity_tests") | ||
engine = BaseEngine(path, path, EngineVelocity) | ||
engine.render_to_file("file_tests.velocity", "file_tests.json", output) | ||
with open(output, "r") as output_file: | ||
expected_path = os.path.join("tests", "fixtures", "velocity_tests", | ||
"expected_output.txt") | ||
with open(expected_path) as expected_file: | ||
expected = expected_file.read() | ||
content = output_file.read() | ||
eq_(content, expected) | ||
os.unlink(output) | ||
|
||
|
||
def test_velocity_string_template(): | ||
string_template = "Hello $hello" | ||
output = "test.txt" | ||
path = os.path.join("tests", "fixtures", "velocity_tests") | ||
engine = BaseEngine(path, path, EngineVelocity) | ||
engine.render_string_to_file(string_template, "file_tests.json", output) | ||
with open(output, "r") as output_file: | ||
expected = "Hello World!" | ||
content = output_file.read() | ||
eq_(content, expected) | ||
os.unlink(output) |