tests: add basic xls export check

This commit is contained in:
Frédéric Péters 2018-03-11 12:17:49 +01:00
parent 9c7c8633f2
commit 98d2204b13
1 changed files with 24 additions and 0 deletions

View File

@ -14,6 +14,11 @@ import zipfile
import pytest
try:
import xlwt
except ImportError:
xlwt = None
from quixote import cleanup, get_publisher
from qommon import ods
from wcs.qommon import errors, sessions
@ -862,6 +867,25 @@ def test_backoffice_ods(pub):
assert row.findall('.//{%s}table-cell' % ods.NS['table'])[old_column].attrib[
'{%s}date-value' % ods.NS['office']] == '1871-03-18'
@pytest.mark.skipif('xlwt is None')
def test_backoffice_xls(pub):
create_superuser(pub)
create_environment(pub)
app = login(get_app(pub))
resp = app.get('/backoffice/management/form-title/')
assert not 'Excel Export' in resp.body
if not pub.site_options.has_section('options'):
pub.site_options.add_section('options')
pub.site_options.set('options', 'legacy-excel-export', 'true')
fd = open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w')
pub.site_options.write(fd)
fd.close()
resp = app.get('/backoffice/management/form-title/')
resp = resp.click('Excel Export')
assert resp.headers['content-type'].startswith('application/vnd.ms-excel')
def test_backoffice_statistics(pub):
create_superuser(pub)
create_environment(pub)