tests: add more backoffice pages tests
This commit is contained in:
parent
cfc2fc6b51
commit
a9a378845c
|
@ -27,6 +27,7 @@ def setup_module(module):
|
|||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
pub.cfg['identification'] = {'methods': ['password']}
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
pub.write_cfg()
|
||||
|
||||
def create_superuser():
|
||||
|
@ -56,17 +57,36 @@ def create_environment(set_receiver=True):
|
|||
formdef.name = 'form title'
|
||||
if set_receiver:
|
||||
formdef.workflow_roles = {'_receiver': '1'}
|
||||
formdef.fields = [fields.StringField(id='1', label='1st field', type='string')]
|
||||
formdef.fields = [fields.StringField(id='1', label='1st field', type='string'),
|
||||
fields.ItemField(id='2', label='2nd field', type='item',
|
||||
items=['foo', 'bar', 'baz']),
|
||||
]
|
||||
formdef.store()
|
||||
formdef.data_class().wipe()
|
||||
for i in range(50):
|
||||
formdata = formdef.data_class()()
|
||||
formdata.just_created()
|
||||
formdata.receipt_time = datetime.datetime(2015, 1, 1).timetuple()
|
||||
formdata.data = {'1': 'FOO BAR %d' % i}
|
||||
if i%3 == 0:
|
||||
formdata.status = 'wf-new'
|
||||
if i%4 == 0:
|
||||
formdata.data['2'] = 'foo'
|
||||
elif i%4 == 1:
|
||||
formdata.data['2'] = 'bar'
|
||||
else:
|
||||
formdata.status = 'wf-finished'
|
||||
formdata.data['2'] = 'baz'
|
||||
if i%3 == 0:
|
||||
formdata.jump_status('new')
|
||||
else:
|
||||
formdata.jump_status('finished')
|
||||
formdata.store()
|
||||
|
||||
formdef = FormDef()
|
||||
formdef.name = 'other form'
|
||||
formdef.store()
|
||||
formdef.data_class().wipe()
|
||||
for i in range(20):
|
||||
formdata = formdef.data_class()()
|
||||
formdata.receipt_time = datetime.datetime(2014, 1, 1).timetuple()
|
||||
formdata.store()
|
||||
|
||||
def teardown_module(module):
|
||||
|
@ -102,7 +122,6 @@ def test_backoffice_forms():
|
|||
resp = resp.click('Management', index=0)
|
||||
assert 'Forms in your care' in resp.body
|
||||
assert '17 open on 50' in resp.body
|
||||
assert not 'Other Forms' in resp.body
|
||||
|
||||
def test_backoffice_listing():
|
||||
create_superuser()
|
||||
|
@ -112,19 +131,26 @@ def test_backoffice_listing():
|
|||
assert resp.body.count('data-link') == 17
|
||||
|
||||
# check status filter <select>
|
||||
resp = app.get('/backoffice/form-title/')
|
||||
resp.forms[0]['filter'] = 'all'
|
||||
resp = resp.forms[0].submit()
|
||||
assert resp.body.count('data-link') == 50 # not using sql -> no pagination
|
||||
|
||||
# check status filter <select>
|
||||
resp = app.get('/backoffice/form-title/')
|
||||
resp.forms[0]['filter'] = 'done'
|
||||
resp = resp.forms[0].submit()
|
||||
assert resp.body.count('data-link') == 33
|
||||
|
||||
def test_backoffice_columns():
|
||||
create_superuser()
|
||||
create_environment()
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/form-title/')
|
||||
assert resp.body.count('</th>') == 5 # five columns
|
||||
assert resp.body.count('</th>') == 6 # five columns
|
||||
resp.forms[0]['1'].checked = False
|
||||
resp = resp.forms[0].submit()
|
||||
assert resp.body.count('</th>') == 4 # four columns
|
||||
assert resp.body.count('</th>') == 5 # four columns
|
||||
assert resp.body.count('data-link') == 17 # 17 rows
|
||||
assert resp.body.count('FOO BAR') == 0 # no field 1 column
|
||||
|
||||
|
@ -162,6 +188,14 @@ def test_backoffice_statistics():
|
|||
assert 'Total number of records: 50' in resp.body
|
||||
assert 'New: 17' in resp.body
|
||||
assert 'Finished: 33' in resp.body
|
||||
assert re.findall('foo.*26.*bar.*26.*bar.*48', resp.body) # percentages
|
||||
assert 'Resolution time' in resp.body
|
||||
assert 'To Status "New"' in resp.body
|
||||
assert 'To Status "Finished"' in resp.body
|
||||
|
||||
resp.forms[0]['end'] = '2013-01-01'
|
||||
resp = resp.forms[0].submit()
|
||||
assert 'Total number of records: 0' in resp.body
|
||||
|
||||
def test_backoffice_handling():
|
||||
create_superuser()
|
||||
|
@ -176,3 +210,16 @@ def test_backoffice_handling():
|
|||
resp = resp.follow()
|
||||
assert form_class.get(31).status == 'wf-accepted'
|
||||
assert 'HELLO WORLD' in resp.body
|
||||
|
||||
def test_global_statistics():
|
||||
create_superuser()
|
||||
create_environment()
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/')
|
||||
resp = resp.click('Global statistics')
|
||||
assert 'Total count: 70' in resp.body
|
||||
|
||||
resp.forms[0]['start'] = '2014-01-01'
|
||||
resp.forms[0]['end'] = '2014-12-31'
|
||||
resp = resp.forms[0].submit()
|
||||
assert 'Total count: 20' in resp.body
|
||||
|
|
Loading…
Reference in New Issue