-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Psycho-rebased branch 77-template-engine-header on top of master
- Loading branch information
Showing
4 changed files
with
93 additions
and
14 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
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,37 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Tests around the functions to select templates.""" | ||
import unittest | ||
try: | ||
from unittest import mock | ||
except ImportError: | ||
import mock | ||
|
||
from piecutter.engines.django import DjangoEngine | ||
from piecutter.engines.jinja import Jinja2Engine | ||
from pyramid.httpexceptions import HTTPNotAcceptable | ||
|
||
from diecutter.service import Service | ||
from diecutter.settings import DEFAULTS | ||
|
||
|
||
class EngineSelectorTestCase(unittest.TestCase): | ||
"""Tests around the functions to select templates.""" | ||
def setUp(self): | ||
self.service = Service() | ||
|
||
def test_engine_factory(self): | ||
request = mock.Mock() | ||
request.registry = mock.Mock() | ||
request.registry.settings = DEFAULTS | ||
|
||
request.headers = {} | ||
self.assertEquals(self.service.get_engine_factory(request), | ||
Jinja2Engine) | ||
|
||
request.headers = {"diecutter_template_engine": 'django'} | ||
self.assertEquals(self.service.get_engine_factory(request), | ||
DjangoEngine) | ||
|
||
request.headers = {"diecutter_template_engine": "<invalid>"} | ||
self.assertRaises(HTTPNotAcceptable, | ||
self.service.get_engine_factory, request) |
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