class TestParser(object): def setup(self): self.parser = Parser() def test_evaluation(self): for test, context, expected in TESTS: ast = self.parser.parse(test) actual = ast.evaluate(context) assert actual == expected def test_include_simple_url(self): requests.get = MagicMock(return_value=ResponseMock('foo')) test = '<!--# include virtual="/foo" -->' ast = self.parser.parse(test) actual = ast.evaluate({}) assert actual == 'foo' def test_include_set_var(self): requests.get = MagicMock(return_value=ResponseMock('foo')) test = '<!--# include virtual="/foo" set="name"--><!--# echo var="name" -->' ast = self.parser.parse(test) actual = ast.evaluate({}) assert actual == 'foo' def test_include_empty_url(self): requests.get = MagicMock(return_value=ResponseMock('')) test = '<!--# block name="name" -->foo<!--# endblock --><!--# include virtual="/" stub="name"-->' ast = self.parser.parse(test) actual = ast.evaluate({}) assert actual == 'foo'
def setup(self): self.parser = Parser()