pricing: publik-django-templatetags integration (#64561)
This commit is contained in:
parent
687fe2e9c3
commit
eb67f72b35
|
@ -121,6 +121,11 @@ TEMPLATES = [
|
||||||
'django.template.context_processors.tz',
|
'django.template.context_processors.tz',
|
||||||
'django.template.context_processors.request',
|
'django.template.context_processors.request',
|
||||||
'django.contrib.messages.context_processors.messages',
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
'publik_django_templatetags.wcs.context_processors.cards',
|
||||||
|
],
|
||||||
|
'builtins': [
|
||||||
|
'publik_django_templatetags.publik.templatetags.publik',
|
||||||
|
'publik_django_templatetags.wcs.templatetags.wcs',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,7 +11,8 @@ Depends: ${misc:Depends}, ${python3:Depends},
|
||||||
python3-django (>= 2:2.2),
|
python3-django (>= 2:2.2),
|
||||||
python3-gadjo,
|
python3-gadjo,
|
||||||
python3-requests,
|
python3-requests,
|
||||||
python3-uwsgidecorators
|
python3-uwsgidecorators,
|
||||||
|
python3-publik-django-templatetags
|
||||||
Recommends: python3-django-mellon
|
Recommends: python3-django-mellon
|
||||||
Description: Agendas System (Python 3 module)
|
Description: Agendas System (Python 3 module)
|
||||||
|
|
||||||
|
|
|
@ -14,3 +14,12 @@ def app(request):
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def media_root(settings, tmpdir):
|
def media_root(settings, tmpdir):
|
||||||
settings.MEDIA_ROOT = str(tmpdir.mkdir('media_root'))
|
settings.MEDIA_ROOT = str(tmpdir.mkdir('media_root'))
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def nocache(settings):
|
||||||
|
settings.CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import json
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from django.template import Context, Template
|
||||||
|
from django.test.client import RequestFactory
|
||||||
|
from publik_django_templatetags.wcs.context_processors import Cards
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def context():
|
||||||
|
return Context(
|
||||||
|
{
|
||||||
|
'cards': Cards(),
|
||||||
|
'request': RequestFactory().get('/'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class MockedRequestResponse(mock.Mock):
|
||||||
|
status_code = 200
|
||||||
|
|
||||||
|
def json(self):
|
||||||
|
return json.loads(self.content)
|
||||||
|
|
||||||
|
|
||||||
|
def mocked_requests_send(request, **kwargs):
|
||||||
|
data = [{'id': 1, 'fields': {'foo': 'bar'}}, {'id': 2, 'fields': {'foo': 'baz'}}] # fake result
|
||||||
|
return MockedRequestResponse(content=json.dumps({'data': data}))
|
||||||
|
|
||||||
|
|
||||||
|
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
||||||
|
def test_publik_django_templatetags_integration(mock_send, context, nocache):
|
||||||
|
t = Template('{{ cards|objects:"foo"|count }}')
|
||||||
|
assert t.render(context) == "2"
|
2
tox.ini
2
tox.ini
|
@ -29,6 +29,7 @@ deps =
|
||||||
django22: django>=2.2,<2.3
|
django22: django>=2.2,<2.3
|
||||||
psycopg2-binary<2.9
|
psycopg2-binary<2.9
|
||||||
codestyle: pre-commit
|
codestyle: pre-commit
|
||||||
|
git+https://git.entrouvert.org/publik-django-templatetags.git
|
||||||
commands =
|
commands =
|
||||||
./getlasso3.sh
|
./getlasso3.sh
|
||||||
python3 setup.py compile_translations
|
python3 setup.py compile_translations
|
||||||
|
@ -50,6 +51,7 @@ deps =
|
||||||
django-mellon>=1.6.1
|
django-mellon>=1.6.1
|
||||||
pytest-freezegun
|
pytest-freezegun
|
||||||
psycopg2-binary<2.9
|
psycopg2-binary<2.9
|
||||||
|
git+https://git.entrouvert.org/publik-django-templatetags.git
|
||||||
commands =
|
commands =
|
||||||
./getlasso3.sh
|
./getlasso3.sh
|
||||||
pylint: ./pylint.sh chrono/ tests/
|
pylint: ./pylint.sh chrono/ tests/
|
||||||
|
|
Loading…
Reference in New Issue