misc: declare dependency on publik-django-templatetags (#83698)
gitea/authentic/pipeline/head This commit looks good Details

This commit is contained in:
Paul Marillonnet 2023-11-24 08:52:34 +01:00
parent 4af1cd8ca6
commit b925bc7b7c
5 changed files with 60 additions and 0 deletions

1
debian/control vendored
View File

@ -38,6 +38,7 @@ Depends: openssl,
python3-ldap (>= 2.4),
python3-markdown (>= 2.1),
python3-pil,
python3-publik-django-templatetags,
python3-pycryptodome,
python3-requests (>=2.3),
python3-requests-oauthlib,

View File

@ -92,6 +92,11 @@ TEMPLATES = [
'django.template.context_processors.static',
'authentic2.context_processors.a2_processor',
'authentic2.context_processors.home',
'publik_django_templatetags.wcs.context_processors.cards',
],
'builtins': [
'publik_django_templatetags.publik.templatetags.publik',
'publik_django_templatetags.wcs.templatetags.wcs',
],
},
},
@ -159,6 +164,7 @@ INSTALLED_APPS = (
'django_rbac',
'authentic2.a2_rbac',
'gadjo',
'publik_django_templatetags',
'rest_framework',
'xstatic.pkg.jquery',
'xstatic.pkg.jquery_ui',

View File

@ -593,3 +593,12 @@ def fc(db):
@pytest.fixture
def nologtoconsole(monkeypatch):
monkeypatch.setattr('authentic2.base_commands.log_to_console', lambda *args: contextlib.nullcontext())
@pytest.fixture
def nocache(settings):
settings.CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}

View File

@ -14,7 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
from unittest import mock
import pytest
from django.test.client import RequestFactory
from publik_django_templatetags.wcs.context_processors import Cards
from authentic2.utils import misc as utils_misc
from authentic2.utils.template import Template, TemplateError
@ -124,3 +129,38 @@ def test_login_with_custom_titles(app, fc):
response = app.get(url)
assert '<h2>Log in with Password</h2>' in response.text
assert '<h2>Log in with FC</h2>' in response.text
@pytest.fixture
def context():
return {
'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'}}]
return MockedRequestResponse(content=json.dumps({'data': data}))
def test_render_publik_django_templatetags_no_context():
value = '{{ cards|objects:"foo"|count }}'
template = Template(value=value)
assert template.render(context=None) == '0'
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
def test_render_publik_django_templatetags(mock_send, context, nocache):
value = '{{ cards|objects:"foo"|count }}'
template = Template(value=value)
assert template.render(context=context) == '2'

View File

@ -69,6 +69,7 @@ deps =
pytz
pytest-freezegun
faker
git+https://git.entrouvert.org/publik-django-templatetags.git
uwsgidecorators
enum34<=1.1.6
ldaptools>=0.24
@ -94,6 +95,7 @@ setenv =
SETUPTOOLS_USE_DISTUTILS=stdlib
deps =
psycopg2-binary
git+https://git.entrouvert.org/publik-django-templatetags.git
allowlist_externals =
./getlasso3.sh
./check-migrations.sh
@ -118,6 +120,7 @@ deps =
lxml
ldaptools
pytest
git+https://git.entrouvert.org/publik-django-templatetags.git
uwsgidecorators
pyquery
numpy
@ -153,6 +156,7 @@ setenv =
DJANGO_SETTINGS_MODULE=authentic2.settings
deps =
psycopg2-binary
git+https://git.entrouvert.org/publik-django-templatetags.git
allowlist_externals =
./getlasso3.sh
./manage.py