Add test templates and use DictLoader in tests
* Add test templates * Update tests to use the updated dict loader without sitename prefix
This commit is contained in:
parent
cb649a8b66
commit
328a1297f6
|
@ -10,3 +10,4 @@ include *.odt
|
|||
include locale/*.po
|
||||
include doc/*
|
||||
include tests/*.rst
|
||||
graft templates
|
||||
|
|
3
setup.py
3
setup.py
|
@ -139,7 +139,8 @@ setup(
|
|||
package_data = {
|
||||
'trytond.modules.nereid': info.get('xml', []) \
|
||||
+ ['tryton.cfg', 'locale/*.po', 'tests/*.rst']
|
||||
+ ['i18n/*.pot', 'i18n/pt_BR/LC_MESSAGES/*'],
|
||||
+ ['i18n/*.pot', 'i18n/pt_BR/LC_MESSAGES/*']
|
||||
+ ['templates/*.*', 'templates/tests/*.*'],
|
||||
},
|
||||
zip_safe=False,
|
||||
platforms='any',
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
This is meant to be a template which will be there in this folder
|
||||
and also in the local templates search path of the test suite.
|
|
@ -0,0 +1 @@
|
|||
from-module
|
|
@ -37,6 +37,26 @@ class TestAddress(NereidTestCase):
|
|||
self.address_obj = POOL.get('party.address')
|
||||
self.contact_mech_obj = POOL.get('party.contact_mechanism')
|
||||
|
||||
self.templates = {
|
||||
'home.jinja': '{{get_flashed_messages()}}',
|
||||
'login.jinja':
|
||||
'{{ login_form.errors }} {{get_flashed_messages()}}',
|
||||
'registration.jinja':
|
||||
'{{ form.errors }} {{get_flashed_messages()}}',
|
||||
'reset-password.jinja': '',
|
||||
'change-password.jinja':
|
||||
'{{ change_password_form.errors }}',
|
||||
'address-edit.jinja':
|
||||
'Address Edit {% if address %}ID:{{ address.id }}{% endif %}'
|
||||
'{{ form.errors }}',
|
||||
'address.jinja': '',
|
||||
'account.jinja': '',
|
||||
'emails/activation-text.jinja': 'activation-email-text',
|
||||
'emails/activation-html.jinja': 'activation-email-html',
|
||||
'emails/reset-text.jinja': 'reset-email-text',
|
||||
'emails/reset-html.jinja': 'reset-email-html',
|
||||
}
|
||||
|
||||
# Patch SMTP Lib
|
||||
self.smtplib_patcher = patch('smtplib.SMTP')
|
||||
self.PatchedSMTP = self.smtplib_patcher.start()
|
||||
|
@ -124,26 +144,7 @@ class TestAddress(NereidTestCase):
|
|||
"""
|
||||
Return templates
|
||||
"""
|
||||
templates = {
|
||||
'localhost/home.jinja': '{{get_flashed_messages()}}',
|
||||
'localhost/login.jinja':
|
||||
'{{ login_form.errors }} {{get_flashed_messages()}}',
|
||||
'localhost/registration.jinja':
|
||||
'{{ form.errors }} {{get_flashed_messages()}}',
|
||||
'localhost/reset-password.jinja': '',
|
||||
'localhost/change-password.jinja':
|
||||
'{{ change_password_form.errors }}',
|
||||
'localhost/address-edit.jinja':
|
||||
'Address Edit {% if address %}ID:{{ address.id }}{% endif %}'
|
||||
'{{ form.errors }}',
|
||||
'localhost/address.jinja': '',
|
||||
'localhost/account.jinja': '',
|
||||
'localhost/emails/activation-text.jinja': 'activation-email-text',
|
||||
'localhost/emails/activation-html.jinja': 'activation-email-html',
|
||||
'localhost/emails/reset-text.jinja': 'reset-email-text',
|
||||
'localhost/emails/reset-html.jinja': 'reset-email-html',
|
||||
}
|
||||
return templates.get(name)
|
||||
return self.templates.get(name)
|
||||
|
||||
def test_0010_add_address(self):
|
||||
"""
|
||||
|
|
|
@ -80,23 +80,23 @@ class TestAuth(NereidTestCase):
|
|||
'guest_user': self.guest_user,
|
||||
}])
|
||||
self.templates = {
|
||||
'localhost/home.jinja': '{{get_flashed_messages()}}',
|
||||
'localhost/login.jinja':
|
||||
'home.jinja': '{{get_flashed_messages()}}',
|
||||
'login.jinja':
|
||||
'{{ login_form.errors }} {{get_flashed_messages()}}',
|
||||
'localhost/registration.jinja':
|
||||
'registration.jinja':
|
||||
'{{ form.errors }} {{get_flashed_messages()}}',
|
||||
'localhost/reset-password.jinja': '',
|
||||
'localhost/change-password.jinja':
|
||||
'reset-password.jinja': '',
|
||||
'change-password.jinja':
|
||||
'''{{ change_password_form.errors }}
|
||||
{{get_flashed_messages()}}''',
|
||||
'localhost/address-edit.jinja': 'Address Edit {{ form.errors }}',
|
||||
'localhost/address.jinja': '',
|
||||
'localhost/account.jinja': '',
|
||||
'localhost/profile.jinja': '{{ request.nereid_user.display_name }}',
|
||||
'localhost/emails/activation-text.jinja': 'activation-email-text',
|
||||
'localhost/emails/activation-html.jinja': 'activation-email-html',
|
||||
'localhost/emails/reset-text.jinja': 'reset-email-text',
|
||||
'localhost/emails/reset-html.jinja': 'reset-email-html',
|
||||
'address-edit.jinja': 'Address Edit {{ form.errors }}',
|
||||
'address.jinja': '',
|
||||
'account.jinja': '',
|
||||
'profile.jinja': '{{ request.nereid_user.display_name }}',
|
||||
'emails/activation-text.jinja': 'activation-email-text',
|
||||
'emails/activation-html.jinja': 'activation-email-html',
|
||||
'emails/reset-text.jinja': 'reset-email-text',
|
||||
'emails/reset-html.jinja': 'reset-email-html',
|
||||
}
|
||||
|
||||
def get_template_source(self, name):
|
||||
|
@ -506,7 +506,7 @@ class TestAuth(NereidTestCase):
|
|||
self.setup_defaults()
|
||||
app = self.get_app()
|
||||
|
||||
self.templates['localhost/home.jinja'] = """
|
||||
self.templates['home.jinja'] = """
|
||||
{{ request.nereid_user.get_profile_picture() }}
|
||||
"""
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ class TestCurrency(NereidTestCase):
|
|||
'currencies': [('set', self.website_currencies)],
|
||||
}])
|
||||
self.templates = {
|
||||
'localhost/home.jinja': '{{ request.nereid_currency.id }}',
|
||||
'home.jinja': '{{ request.nereid_currency.id }}',
|
||||
}
|
||||
|
||||
def get_template_source(self, name):
|
||||
|
|
|
@ -69,7 +69,7 @@ class TestI18N(NereidTestCase):
|
|||
Return templates
|
||||
"""
|
||||
templates = {
|
||||
'localhost/home.jinja': '{{get_flashed_messages()}}',
|
||||
'home.jinja': '{{get_flashed_messages()}}',
|
||||
}
|
||||
return templates.get(name)
|
||||
|
||||
|
|
|
@ -47,6 +47,14 @@ class TestStaticFile(NereidTestCase):
|
|||
self.static_file_obj = POOL.get('nereid.static.file')
|
||||
self.static_folder_obj = POOL.get('nereid.static.folder')
|
||||
|
||||
self.templates = {
|
||||
'home.jinja':
|
||||
'''
|
||||
{% set static_file = static_file_obj(static_file_id) %}
|
||||
{{ static_file.url }}
|
||||
''',
|
||||
}
|
||||
|
||||
def setup_defaults(self):
|
||||
"""
|
||||
Setup the defaults
|
||||
|
@ -85,20 +93,6 @@ class TestStaticFile(NereidTestCase):
|
|||
'guest_user': self.guest_user,
|
||||
}])
|
||||
|
||||
def get_template_source(self, name):
|
||||
"""
|
||||
Return templates
|
||||
"""
|
||||
templates = {
|
||||
'localhost/home.jinja':
|
||||
'''
|
||||
{% set static_file = static_file_obj(static_file_id) %}
|
||||
{{ static_file.url }}
|
||||
''',
|
||||
|
||||
}
|
||||
return templates.get(name)
|
||||
|
||||
def create_static_file(self, file_buffer):
|
||||
"""
|
||||
Creates the static file for testing
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=2.8.0.1
|
||||
version=2.8.0.2
|
||||
depends:
|
||||
ir
|
||||
res
|
||||
|
|
Loading…
Reference in New Issue