Skip to content

Commit

Permalink
Merge pull request #235 from Kinto/remove-check-about-template-variables
Browse files Browse the repository at this point in the history
Remove check of about template variables
  • Loading branch information
leplatrem authored Dec 1, 2020
2 parents 00da24d + b665a04 commit a4652ee
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: python
python: 3.6
python: 3.8
env:
- TOX_ENV=py36
- TOX_ENV=py38
- TOX_ENV=kinto-master
- TOX_ENV=flake8
install:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This document describes changes between each past release.
1.2.0 (unreleased)
------------------

- Nothing changed yet.
- Remove template variable validation


1.1.0 (2019-02-20)
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ OBJECTS = .venv .coverage

all: install
install: $(INSTALL_STAMP)
$(INSTALL_STAMP): $(PYTHON) setup.py
$(INSTALL_STAMP): $(PYTHON) requirements.txt setup.py
$(VENV)/bin/pip install -r requirements.txt
$(PYTHON) setup.py develop
touch $(INSTALL_STAMP)

Expand Down
9 changes: 1 addition & 8 deletions kinto_emailer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,10 @@ def _validate_emailer_settings(event):

for hook in hooks:
try:
template = hook['template']
hook['template']
except KeyError:
raise_invalid(request, description='Missing "template".')

try:
context = context_from_event(event)
template.format(**context)
except KeyError as e:
error_msg = 'Invalid template variable: %s' % e
raise_invalid(request, description=error_msg)

recipients = hook.get('recipients', [])
if not recipients:
raise_invalid(request, description='Empty list of recipients.')
Expand Down
9 changes: 0 additions & 9 deletions kinto_emailer/tests/test_includeme.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,12 +558,3 @@ def test_fails_if_group_uri_is_invalid(self):
headers=self.headers,
status=400)
assert 'Invalid recipients /buckets/b/group/g' in r.json['message']

def test_fails_if_template_contains_bad_placeholders(self):
tpl = 'The current temperature is {degres}C.'
self.valid_collection['kinto-emailer']['hooks'][0]['template'] = tpl
r = self.app.put_json('/buckets/b/collections/c',
{'data': self.valid_collection},
headers=self.headers,
status=400)
assert 'degres' in r.json['message']
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py35,kinto-master,flake8,functional
envlist = py38,kinto-master,flake8,functional
skip_missing_interpreters = True

[testenv]
Expand Down

0 comments on commit a4652ee

Please sign in to comment.