This repository has been archived by the owner on Feb 27, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds global context processors w/ tests
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 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,31 @@ | ||
import jingo | ||
import jinja2 | ||
from nose.tools import eq_ | ||
from test_utils import TestCase, RequestFactory | ||
|
||
|
||
class TestContext(TestCase): | ||
|
||
def setUp(self): | ||
self.factory = RequestFactory() | ||
|
||
def render(self, content, request=None): | ||
if not request: | ||
request = self.factory.get('/') | ||
tpl = jinja2.Template(content) | ||
return jingo.render_to_string(request, tpl) | ||
|
||
def test_request(self): | ||
eq_(self.render('{{ request.path }}'), '/') | ||
|
||
def test_settings(self): | ||
eq_(self.render('{{ settings.SITE_ID }}'), '1') | ||
|
||
def test_languages(self): | ||
eq_(self.render("{{ LANGUAGES['en-us'] }}"), 'English (US)') | ||
|
||
def test_languages(self): | ||
eq_(self.render("{{ LANG }}"), 'en-US') | ||
|
||
def test_lang_dir(self): | ||
eq_(self.render("{{ DIR }}"), 'ltr') |