61 |
61 |
shutil.rmtree(pub.APP_DIR)
|
62 |
62 |
|
63 |
63 |
def test_empty_site():
|
64 |
|
get_app(pub).get('/admin/')
|
|
64 |
get_app(pub).get('/backoffice/')
|
65 |
65 |
|
66 |
66 |
def test_with_user():
|
67 |
67 |
create_superuser()
|
68 |
|
resp = get_app(pub).get('/admin/', status=302)
|
|
68 |
resp = get_app(pub).get('/backoffice/', status=302)
|
69 |
69 |
resp = resp.follow()
|
70 |
70 |
assert resp.location == 'http://example.net/login/'
|
71 |
71 |
|
72 |
72 |
def test_with_superuser():
|
73 |
73 |
app = login(get_app(pub))
|
74 |
|
app.get('/admin/')
|
|
74 |
app.get('/backoffice/')
|
75 |
75 |
|
76 |
76 |
def test_forms():
|
77 |
77 |
app = login(get_app(pub))
|
78 |
|
resp = app.get('/admin/forms/')
|
|
78 |
resp = app.get('/backoffice/forms/')
|
79 |
79 |
assert 'You first have to define roles.' in resp.body
|
80 |
80 |
assert not 'New Form' in resp.body
|
81 |
81 |
|
... | ... | |
84 |
84 |
create_role()
|
85 |
85 |
|
86 |
86 |
# create a new form
|
87 |
|
resp = app.get('/admin/forms/')
|
|
87 |
resp = app.get('/backoffice/forms/')
|
88 |
88 |
assert 'New Form' in resp.body
|
89 |
89 |
resp = resp.click('New Form')
|
90 |
90 |
resp.forms[0]['name'] = 'form title'
|
91 |
91 |
resp = resp.forms[0].submit()
|
92 |
|
assert resp.location == 'http://example.net/admin/forms/1/'
|
|
92 |
assert resp.location == 'http://example.net/backoffice/forms/1/'
|
93 |
93 |
resp = resp.follow()
|
94 |
94 |
assert 'Form - form title' in resp.body
|
95 |
95 |
|
... | ... | |
111 |
111 |
formdef.store()
|
112 |
112 |
|
113 |
113 |
app = login(get_app(pub))
|
114 |
|
resp = app.get('/admin/forms/1/')
|
|
114 |
resp = app.get('/backoffice/forms/1/')
|
115 |
115 |
|
116 |
116 |
# try changing an option
|
117 |
117 |
assert 'Include confirmation page' in resp.body
|
... | ... | |
119 |
119 |
assert resp.forms[0]['confirmation'].checked
|
120 |
120 |
resp.forms[0]['confirmation'].checked = False
|
121 |
121 |
resp = resp.forms[0].submit()
|
122 |
|
assert resp.location == 'http://example.net/admin/forms/1/'
|
|
122 |
assert resp.location == 'http://example.net/backoffice/forms/1/'
|
123 |
123 |
resp = resp.follow()
|
124 |
124 |
assert not 'Include confirmation page' in resp.body
|
125 |
125 |
assert FormDef.get(1).confirmation == False
|
126 |
126 |
|
127 |
127 |
# try changing title
|
128 |
|
resp = app.get('/admin/forms/1/')
|
|
128 |
resp = app.get('/backoffice/forms/1/')
|
129 |
129 |
resp = resp.click(href='title')
|
130 |
130 |
assert resp.forms[0]['name'].value == 'form title'
|
131 |
131 |
resp.forms[0]['name'] = 'new title'
|
132 |
132 |
resp = resp.forms[0].submit()
|
133 |
|
assert resp.location == 'http://example.net/admin/forms/1/'
|
|
133 |
assert resp.location == 'http://example.net/backoffice/forms/1/'
|
134 |
134 |
resp = resp.follow()
|
135 |
135 |
assert FormDef.get(1).name == 'new title'
|
136 |
136 |
assert FormDef.get(1).url_name == 'new-title'
|
... | ... | |
146 |
146 |
formdef.store()
|
147 |
147 |
|
148 |
148 |
app = login(get_app(pub))
|
149 |
|
resp = app.get('/admin/forms/1/')
|
|
149 |
resp = app.get('/backoffice/forms/1/')
|
150 |
150 |
assert 'Category:' not in resp.body
|
151 |
151 |
|
152 |
152 |
Category.wipe()
|
... | ... | |
154 |
154 |
cat.store()
|
155 |
155 |
cat = Category(name='Bar')
|
156 |
156 |
cat.store()
|
157 |
|
resp = app.get('/admin/forms/1/')
|
|
157 |
resp = app.get('/backoffice/forms/1/')
|
158 |
158 |
assert 'Category:' in resp.body
|
159 |
159 |
|
160 |
160 |
def test_form_category_select():
|
... | ... | |
174 |
174 |
cat.store()
|
175 |
175 |
|
176 |
176 |
app = login(get_app(pub))
|
177 |
|
resp = app.get('/admin/forms/1/')
|
|
177 |
resp = app.get('/backoffice/forms/1/')
|
178 |
178 |
resp = resp.click(href='category')
|
179 |
179 |
resp = resp.forms[0].submit('cancel')
|
180 |
180 |
assert FormDef.get(formdef.id).category_id is None
|
181 |
181 |
|
182 |
|
resp = app.get('/admin/forms/1/')
|
|
182 |
resp = app.get('/backoffice/forms/1/')
|
183 |
183 |
resp = resp.click(href='category')
|
184 |
184 |
resp.forms[0]['category_id'] = cat.id
|
185 |
185 |
resp = resp.forms[0].submit('submit')
|
... | ... | |
196 |
196 |
formdef.store()
|
197 |
197 |
|
198 |
198 |
app = login(get_app(pub))
|
199 |
|
resp = app.get('/admin/forms/1/')
|
|
199 |
resp = app.get('/backoffice/forms/1/')
|
200 |
200 |
assert 'Workflow:' not in resp.body
|
201 |
201 |
|
202 |
202 |
Workflow.wipe()
|
... | ... | |
205 |
205 |
workflow = Workflow(name='Workflow Two')
|
206 |
206 |
workflow.store()
|
207 |
207 |
|
208 |
|
resp = app.get('/admin/forms/1/')
|
|
208 |
resp = app.get('/backoffice/forms/1/')
|
209 |
209 |
assert 'Workflow:' in resp.body
|
210 |
210 |
|
211 |
211 |
def test_form_workflow_change():
|
... | ... | |
226 |
226 |
workflow.store()
|
227 |
227 |
|
228 |
228 |
app = login(get_app(pub))
|
229 |
|
resp = app.get('/admin/forms/1/')
|
|
229 |
resp = app.get('/backoffice/forms/1/')
|
230 |
230 |
resp = resp.click('change', href='workflow')
|
231 |
231 |
resp = resp.forms[0].submit('cancel')
|
232 |
232 |
assert FormDef.get(formdef.id).workflow_id is None
|
233 |
233 |
|
234 |
|
resp = app.get('/admin/forms/1/')
|
|
234 |
resp = app.get('/backoffice/forms/1/')
|
235 |
235 |
resp = resp.click('change', href='workflow')
|
236 |
236 |
assert 'Workflow One' not in resp.body # this workflow doesn't have any status
|
237 |
237 |
resp.forms[0]['workflow_id'] = workflow.id
|
... | ... | |
263 |
263 |
workflow.store()
|
264 |
264 |
|
265 |
265 |
app = login(get_app(pub))
|
266 |
|
resp = app.get('/admin/forms/1/')
|
|
266 |
resp = app.get('/backoffice/forms/1/')
|
267 |
267 |
resp = resp.click('change', href='workflow')
|
268 |
268 |
resp.forms[0]['workflow_id'] = workflow.id
|
269 |
269 |
resp = resp.forms[0].submit('submit')
|
270 |
|
assert resp.location == 'http://example.net/admin/forms/1/workflow-status-remapping?new=2'
|
|
270 |
assert resp.location == 'http://example.net/backoffice/forms/1/workflow-status-remapping?new=2'
|
271 |
271 |
resp = resp.follow()
|
272 |
272 |
for status in Workflow.get_default_workflow().possible_status:
|
273 |
273 |
assert resp.forms[0]['mapping-%s' % status.id]
|
... | ... | |
288 |
288 |
formdef.store()
|
289 |
289 |
|
290 |
290 |
app = login(get_app(pub))
|
291 |
|
resp = app.get('/admin/forms/1/')
|
|
291 |
resp = app.get('/backoffice/forms/1/')
|
292 |
292 |
resp = resp.click('change', href='role/_receiver')
|
293 |
293 |
resp = resp.forms[0].submit('cancel')
|
294 |
294 |
|
295 |
|
resp = app.get('/admin/forms/1/')
|
|
295 |
resp = app.get('/backoffice/forms/1/')
|
296 |
296 |
resp = resp.click('change', href='role/_receiver')
|
297 |
297 |
resp.forms[0]['role_id'] = 'foobar'
|
298 |
298 |
resp = resp.forms[0].submit('submit')
|
... | ... | |
315 |
315 |
formdef.store()
|
316 |
316 |
|
317 |
317 |
app = login(get_app(pub))
|
318 |
|
resp = app.get('/admin/forms/1/')
|
|
318 |
resp = app.get('/backoffice/forms/1/')
|
319 |
319 |
assert '"workflow-options"' in resp.body
|
320 |
320 |
|
321 |
321 |
def test_form_workflow_variables():
|
... | ... | |
338 |
338 |
formdef.store()
|
339 |
339 |
|
340 |
340 |
app = login(get_app(pub))
|
341 |
|
resp = app.get('/admin/forms/1/')
|
|
341 |
resp = app.get('/backoffice/forms/1/')
|
342 |
342 |
assert '"workflow-variables"' in resp.body
|
343 |
343 |
|
344 |
344 |
# visit the variables page
|
... | ... | |
347 |
347 |
# and set a value
|
348 |
348 |
resp.forms[0]['f1'] = 'foobar'
|
349 |
349 |
resp = resp.forms[0].submit()
|
350 |
|
assert resp.location == 'http://example.net/admin/forms/1/'
|
|
350 |
assert resp.location == 'http://example.net/backoffice/forms/1/'
|
351 |
351 |
|
352 |
352 |
# check the value has been correctly saved
|
353 |
353 |
assert FormDef.get(formdef.id).workflow_options == {'test': 'foobar'}
|
... | ... | |
358 |
358 |
assert resp.forms[0]['f1'].value == 'foobar'
|
359 |
359 |
resp.forms[0]['f1'] = 'barbaz'
|
360 |
360 |
resp = resp.forms[0].submit('cancel')
|
361 |
|
assert resp.location == 'http://example.net/admin/forms/1/'
|
|
361 |
assert resp.location == 'http://example.net/backoffice/forms/1/'
|
362 |
362 |
|
363 |
363 |
def test_form_acl_read():
|
364 |
364 |
create_superuser()
|
... | ... | |
371 |
371 |
formdef.store()
|
372 |
372 |
|
373 |
373 |
app = login(get_app(pub))
|
374 |
|
resp = app.get('/admin/forms/1/')
|
|
374 |
resp = app.get('/backoffice/forms/1/')
|
375 |
375 |
resp = resp.click('change', href='acl-read')
|
376 |
376 |
resp = resp.forms[0].submit('cancel')
|
377 |
377 |
|
378 |
|
resp = app.get('/admin/forms/1/')
|
|
378 |
resp = app.get('/backoffice/forms/1/')
|
379 |
379 |
resp = resp.click('change', href='acl-read')
|
380 |
380 |
resp.forms[0]['acl_read'] = 'Everybody'
|
381 |
381 |
resp = resp.forms[0].submit('submit')
|
... | ... | |
392 |
392 |
formdef.store()
|
393 |
393 |
|
394 |
394 |
app = login(get_app(pub))
|
395 |
|
resp = app.get('/admin/forms/1/')
|
|
395 |
resp = app.get('/backoffice/forms/1/')
|
396 |
396 |
resp = resp.click('change', href='roles')
|
397 |
397 |
resp = resp.forms[0].submit('cancel')
|
398 |
398 |
|
399 |
|
resp = app.get('/admin/forms/1/')
|
|
399 |
resp = app.get('/backoffice/forms/1/')
|
400 |
400 |
resp = resp.click('change', href='roles')
|
401 |
401 |
resp.forms[0]['always_advertise'] = True
|
402 |
402 |
resp = resp.forms[0].submit('submit')
|
... | ... | |
412 |
412 |
formdef.store()
|
413 |
413 |
|
414 |
414 |
app = login(get_app(pub))
|
415 |
|
resp = app.get('/admin/forms/1/')
|
|
415 |
resp = app.get('/backoffice/forms/1/')
|
416 |
416 |
|
417 |
417 |
resp = resp.click(href='delete')
|
418 |
418 |
resp = resp.forms[0].submit()
|
419 |
|
assert resp.location == 'http://example.net/admin/forms/'
|
|
419 |
assert resp.location == 'http://example.net/backoffice/forms/'
|
420 |
420 |
resp = resp.follow()
|
421 |
421 |
assert FormDef.count() == 0
|
422 |
422 |
|
... | ... | |
430 |
430 |
formdef.store()
|
431 |
431 |
|
432 |
432 |
app = login(get_app(pub))
|
433 |
|
resp = app.get('/admin/forms/1/')
|
|
433 |
resp = app.get('/backoffice/forms/1/')
|
434 |
434 |
|
435 |
435 |
resp = resp.click(href='duplicate')
|
436 |
|
assert resp.location == 'http://example.net/admin/forms/2/'
|
|
436 |
assert resp.location == 'http://example.net/backoffice/forms/2/'
|
437 |
437 |
resp = resp.follow()
|
438 |
438 |
assert FormDef.count() == 2
|
439 |
439 |
assert FormDef.get(2).name == 'form title (copy)'
|
440 |
440 |
|
441 |
|
resp = app.get('/admin/forms/1/')
|
|
441 |
resp = app.get('/backoffice/forms/1/')
|
442 |
442 |
resp = resp.click(href='duplicate')
|
443 |
|
assert resp.location == 'http://example.net/admin/forms/3/'
|
|
443 |
assert resp.location == 'http://example.net/backoffice/forms/3/'
|
444 |
444 |
resp = resp.follow()
|
445 |
445 |
assert FormDef.count() == 3
|
446 |
446 |
assert FormDef.get(3).name == 'form title (copy 2)'
|
... | ... | |
455 |
455 |
formdef.store()
|
456 |
456 |
|
457 |
457 |
app = login(get_app(pub))
|
458 |
|
resp = app.get('/admin/forms/1/')
|
|
458 |
resp = app.get('/backoffice/forms/1/')
|
459 |
459 |
|
460 |
460 |
resp = resp.click(href='export')
|
461 |
461 |
xml_export = resp.body
|
... | ... | |
474 |
474 |
formdef.store()
|
475 |
475 |
|
476 |
476 |
app = login(get_app(pub))
|
477 |
|
resp = app.get('/admin/forms/1/')
|
|
477 |
resp = app.get('/backoffice/forms/1/')
|
478 |
478 |
|
479 |
479 |
resp = resp.click(href='qrcode')
|
480 |
480 |
assert '<div id="qrcode">' in resp.body
|
... | ... | |
490 |
490 |
formdef.store()
|
491 |
491 |
|
492 |
492 |
app = login(get_app(pub))
|
493 |
|
resp = app.get('/admin/forms/1/')
|
|
493 |
resp = app.get('/backoffice/forms/1/')
|
494 |
494 |
assert 'No description or keywords' in resp.body
|
495 |
495 |
|
496 |
496 |
resp = resp.click(href='information')
|
497 |
497 |
resp.forms[0]['description'].value = '<p>Hello World</p>'
|
498 |
498 |
resp = resp.forms[0].submit()
|
499 |
|
assert resp.location == 'http://example.net/admin/forms/1/'
|
|
499 |
assert resp.location == 'http://example.net/backoffice/forms/1/'
|
500 |
500 |
resp = resp.follow()
|
501 |
501 |
assert 'No description or keywords' not in resp.body
|
502 |
502 |
assert 'Hello World' in resp.body
|
... | ... | |
512 |
512 |
formdef.store()
|
513 |
513 |
|
514 |
514 |
app = login(get_app(pub))
|
515 |
|
resp = app.get('/admin/forms/1/')
|
|
515 |
resp = app.get('/backoffice/forms/1/')
|
516 |
516 |
resp = resp.click(href='fields/')
|
517 |
517 |
assert 'There are not yet any fields for this form' in resp.body
|
518 |
518 |
|
519 |
519 |
resp.forms[0]['label'] = 'foobar'
|
520 |
520 |
resp.forms[0]['type'] = 'Text (line)'
|
521 |
521 |
resp = resp.forms[0].submit()
|
522 |
|
assert resp.location == 'http://example.net/admin/forms/1/fields/'
|
|
522 |
assert resp.location == 'http://example.net/backoffice/forms/1/fields/'
|
523 |
523 |
resp = resp.follow()
|
524 |
524 |
assert 'foobar' in resp.body
|
525 |
525 |
assert 'Use drag and drop to reorder fields.' in resp.body
|
... | ... | |
532 |
532 |
resp.forms[0]['label'] = 'baz'
|
533 |
533 |
resp.forms[0]['type'] = 'Title'
|
534 |
534 |
resp = resp.forms[0].submit()
|
535 |
|
assert resp.location == 'http://example.net/admin/forms/1/fields/'
|
|
535 |
assert resp.location == 'http://example.net/backoffice/forms/1/fields/'
|
536 |
536 |
resp = resp.follow()
|
537 |
537 |
|
538 |
538 |
# check it's in the preview
|
539 |
|
resp = app.get('/admin/forms/1/')
|
|
539 |
resp = app.get('/backoffice/forms/1/')
|
540 |
540 |
assert '<h3>baz</h3>' in resp.body
|
541 |
541 |
|
542 |
542 |
def test_form_delete_field():
|
... | ... | |
549 |
549 |
formdef.store()
|
550 |
550 |
|
551 |
551 |
app = login(get_app(pub))
|
552 |
|
resp = app.get('/admin/forms/1/')
|
|
552 |
resp = app.get('/backoffice/forms/1/')
|
553 |
553 |
resp = resp.click(href='fields/')
|
554 |
554 |
assert '1st field' in resp.body
|
555 |
555 |
assert 'Use drag and drop to reorder fields.' in resp.body
|
556 |
556 |
|
557 |
557 |
resp = resp.click(href='1/delete')
|
558 |
558 |
resp = resp.forms[0].submit()
|
559 |
|
assert resp.location == 'http://example.net/admin/forms/1/fields/'
|
|
559 |
assert resp.location == 'http://example.net/backoffice/forms/1/fields/'
|
560 |
560 |
resp = resp.follow()
|
561 |
561 |
assert len(FormDef.get(1).fields) == 0
|
562 |
562 |
|
... | ... | |
570 |
570 |
formdef.store()
|
571 |
571 |
|
572 |
572 |
app = login(get_app(pub))
|
573 |
|
resp = app.get('/admin/forms/1/')
|
|
573 |
resp = app.get('/backoffice/forms/1/')
|
574 |
574 |
resp = resp.click(href='fields/')
|
575 |
575 |
assert '1st field' in resp.body
|
576 |
576 |
|
577 |
577 |
resp = resp.click(href='1/duplicate')
|
578 |
|
assert resp.location == 'http://example.net/admin/forms/1/fields/'
|
|
578 |
assert resp.location == 'http://example.net/backoffice/forms/1/fields/'
|
579 |
579 |
resp = resp.follow()
|
580 |
580 |
assert len(FormDef.get(1).fields) == 2
|
581 |
581 |
assert FormDef.get(1).fields[0].label == '1st field'
|
... | ... | |
591 |
591 |
formdef.store()
|
592 |
592 |
|
593 |
593 |
app = login(get_app(pub))
|
594 |
|
resp = app.get('/admin/forms/1/')
|
|
594 |
resp = app.get('/backoffice/forms/1/')
|
595 |
595 |
resp = resp.click(href='fields/')
|
596 |
596 |
assert '1st field' in resp.body
|
597 |
597 |
|
... | ... | |
600 |
600 |
resp.forms[0]['label'] = 'changed field'
|
601 |
601 |
resp.forms[0]['required'] = False
|
602 |
602 |
resp = resp.forms[0].submit('submit')
|
603 |
|
assert resp.location == 'http://example.net/admin/forms/1/fields/'
|
|
603 |
assert resp.location == 'http://example.net/backoffice/forms/1/fields/'
|
604 |
604 |
|
605 |
605 |
assert FormDef.get(1).fields[0].label == 'changed field'
|
606 |
606 |
assert FormDef.get(1).fields[0].required == False
|
... | ... | |
616 |
616 |
formdef.store()
|
617 |
617 |
|
618 |
618 |
app = login(get_app(pub))
|
619 |
|
resp = app.get('/admin/forms/1/')
|
|
619 |
resp = app.get('/backoffice/forms/1/')
|
620 |
620 |
resp = resp.click(href='fields/')
|
621 |
621 |
assert '1st field' in resp.body
|
622 |
622 |
|
... | ... | |
639 |
639 |
# complete it
|
640 |
640 |
resp.forms[0]['prefill$value'] = 'test'
|
641 |
641 |
resp = resp.forms[0].submit('submit')
|
642 |
|
assert resp.location == 'http://example.net/admin/forms/1/fields/'
|
|
642 |
assert resp.location == 'http://example.net/backoffice/forms/1/fields/'
|
643 |
643 |
resp = resp.follow()
|
644 |
644 |
|
645 |
645 |
assert FormDef.get(formdef.id).fields[0].prefill == {'type': 'string', 'value': 'test'}
|
... | ... | |
663 |
663 |
|
664 |
664 |
def test_workflows():
|
665 |
665 |
app = login(get_app(pub))
|
666 |
|
app.get('/admin/workflows/')
|
|
666 |
app.get('/backoffice/workflows/')
|
667 |
667 |
|
668 |
668 |
def test_workflows_default():
|
669 |
669 |
app = login(get_app(pub))
|
670 |
|
resp = app.get('/admin/workflows/')
|
|
670 |
resp = app.get('/backoffice/workflows/')
|
671 |
671 |
assert 'Default' in resp.body
|
672 |
672 |
resp = resp.click(href='_default')
|
673 |
673 |
assert 'Just Submitted' in resp.body
|
... | ... | |
684 |
684 |
def test_workflows_new():
|
685 |
685 |
Workflow.wipe()
|
686 |
686 |
app = login(get_app(pub))
|
687 |
|
resp = app.get('/admin/workflows/')
|
|
687 |
resp = app.get('/backoffice/workflows/')
|
688 |
688 |
|
689 |
689 |
# create a new workflow
|
690 |
690 |
resp = resp.click('New Workflow')
|
691 |
691 |
resp.forms[0]['name'] = 'a new workflow'
|
692 |
692 |
resp = resp.forms[0].submit('submit')
|
693 |
|
assert resp.location == 'http://example.net/admin/workflows/1/'
|
|
693 |
assert resp.location == 'http://example.net/backoffice/workflows/1/'
|
694 |
694 |
resp = resp.follow()
|
695 |
695 |
assert 'There are not yet any status defined in this workflow' in resp.body
|
696 |
696 |
assert not '<svg ' in resp.body
|
... | ... | |
698 |
698 |
# create a new status
|
699 |
699 |
resp.forms[0]['name'] = 'new status'
|
700 |
700 |
resp = resp.forms[0].submit()
|
701 |
|
assert resp.location == 'http://example.net/admin/workflows/1/'
|
|
701 |
assert resp.location == 'http://example.net/backoffice/workflows/1/'
|
702 |
702 |
resp = resp.follow()
|
703 |
703 |
assert '<svg ' in resp.body
|
704 |
704 |
|
... | ... | |
706 |
706 |
resp = resp.click('new status')
|
707 |
707 |
resp.forms[0]['type'] = 'Display message'
|
708 |
708 |
resp = resp.forms[0].submit()
|
709 |
|
assert resp.location == 'http://example.net/admin/workflows/1/status/1/'
|
|
709 |
assert resp.location == 'http://example.net/backoffice/workflows/1/status/1/'
|
710 |
710 |
resp = resp.follow()
|
711 |
711 |
assert 'Use drag and drop to reorder items' in resp.body
|
712 |
712 |
|
... | ... | |
714 |
714 |
resp = resp.click('Display message')
|
715 |
715 |
resp.forms[0]['message'] = 'bla bla bla'
|
716 |
716 |
resp = resp.forms[0].submit('submit')
|
717 |
|
assert resp.location == 'http://example.net/admin/workflows/1/status/1/items/'
|
|
717 |
assert resp.location == 'http://example.net/backoffice/workflows/1/status/1/items/'
|
718 |
718 |
resp = resp.follow()
|
719 |
|
assert resp.location == 'http://example.net/admin/workflows/1/status/1/'
|
|
719 |
assert resp.location == 'http://example.net/backoffice/workflows/1/status/1/'
|
720 |
720 |
|
721 |
721 |
wf = Workflow.get(1)
|
722 |
722 |
assert wf.name == 'a new workflow'
|
... | ... | |
729 |
729 |
workflow.store()
|
730 |
730 |
|
731 |
731 |
app = login(get_app(pub))
|
732 |
|
resp = app.get('/admin/workflows/1/')
|
|
732 |
resp = app.get('/backoffice/workflows/1/')
|
733 |
733 |
resp = resp.click(href='edit')
|
734 |
734 |
assert resp.forms[0]['name'].value == 'foo'
|
735 |
735 |
resp.forms[0]['name'] = 'baz'
|
736 |
736 |
resp = resp.forms[0].submit('submit')
|
737 |
|
assert resp.location == 'http://example.net/admin/workflows/'
|
|
737 |
assert resp.location == 'http://example.net/backoffice/workflows/'
|
738 |
738 |
resp = resp.follow()
|
739 |
739 |
assert 'baz' in resp.body
|
740 |
740 |
|
... | ... | |
745 |
745 |
workflow.store()
|
746 |
746 |
|
747 |
747 |
app = login(get_app(pub))
|
748 |
|
resp = app.get('/admin/workflows/1/')
|
|
748 |
resp = app.get('/backoffice/workflows/1/')
|
749 |
749 |
resp = resp.click('baz')
|
750 |
750 |
|
751 |
751 |
resp = resp.click('Change Status Name')
|
752 |
752 |
resp.forms[0]['name'] = 'bza'
|
753 |
753 |
resp = resp.forms[0].submit()
|
754 |
|
assert resp.location == 'http://example.net/admin/workflows/1/status/1/'
|
|
754 |
assert resp.location == 'http://example.net/backoffice/workflows/1/status/1/'
|
755 |
755 |
resp = resp.follow()
|
756 |
756 |
assert Workflow.get(1).possible_status[0].name == 'bza'
|
757 |
757 |
|
758 |
758 |
resp = resp.click('Change Status Visibility')
|
759 |
759 |
resp.forms[0]['hide_status_from_user'].checked = True
|
760 |
760 |
resp = resp.forms[0].submit()
|
761 |
|
assert resp.location == 'http://example.net/admin/workflows/1/status/1/'
|
|
761 |
assert resp.location == 'http://example.net/backoffice/workflows/1/status/1/'
|
762 |
762 |
resp = resp.follow()
|
763 |
763 |
assert Workflow.get(1).possible_status[0].visibility == ['_receiver']
|
764 |
764 |
|
765 |
765 |
resp = resp.click('Change Terminal Status')
|
766 |
766 |
resp.forms[0]['force_terminal_status'].checked = True
|
767 |
767 |
resp = resp.forms[0].submit()
|
768 |
|
assert resp.location == 'http://example.net/admin/workflows/1/status/1/'
|
|
768 |
assert resp.location == 'http://example.net/backoffice/workflows/1/status/1/'
|
769 |
769 |
resp = resp.follow()
|
770 |
770 |
assert Workflow.get(1).possible_status[0].forced_endpoint == True
|
771 |
771 |
|
... | ... | |
773 |
773 |
assert resp.forms[0]['colour'].value == 'FFFFFF'
|
774 |
774 |
resp.forms[0]['colour'] = 'FF0000'
|
775 |
775 |
resp = resp.forms[0].submit()
|
776 |
|
assert resp.location == 'http://example.net/admin/workflows/1/status/1/'
|
|
776 |
assert resp.location == 'http://example.net/backoffice/workflows/1/status/1/'
|
777 |
777 |
resp = resp.follow()
|
778 |
778 |
assert Workflow.get(1).possible_status[0].colour == 'FF0000'
|
779 |
779 |
|
... | ... | |
783 |
783 |
workflow.store()
|
784 |
784 |
|
785 |
785 |
app = login(get_app(pub))
|
786 |
|
resp = app.get('/admin/workflows/1/')
|
|
786 |
resp = app.get('/backoffice/workflows/1/')
|
787 |
787 |
|
788 |
788 |
resp = resp.click(href='delete')
|
789 |
789 |
resp = resp.forms[0].submit()
|
790 |
|
assert resp.location == 'http://example.net/admin/workflows/'
|
|
790 |
assert resp.location == 'http://example.net/backoffice/workflows/'
|
791 |
791 |
resp = resp.follow()
|
792 |
792 |
assert Workflow.count() == 0
|
793 |
793 |
|
... | ... | |
798 |
798 |
workflow.store()
|
799 |
799 |
|
800 |
800 |
app = login(get_app(pub))
|
801 |
|
resp = app.get('/admin/workflows/1/')
|
|
801 |
resp = app.get('/backoffice/workflows/1/')
|
802 |
802 |
resp = resp.click('baz')
|
803 |
803 |
|
804 |
804 |
for action in [x[0] for x in resp.forms[0]['type'].options]:
|
... | ... | |
821 |
821 |
workflow.store()
|
822 |
822 |
|
823 |
823 |
app = login(get_app(pub))
|
824 |
|
resp = app.get('/admin/workflows/1/')
|
|
824 |
resp = app.get('/backoffice/workflows/1/')
|
825 |
825 |
resp = resp.click(href='variables/')
|
826 |
|
assert resp.location == 'http://example.net/admin/workflows/1/variables/fields/'
|
|
826 |
assert resp.location == 'http://example.net/backoffice/workflows/1/variables/fields/'
|
827 |
827 |
resp = resp.follow()
|
828 |
828 |
|
829 |
829 |
# makes sure we can't add page fields
|
... | ... | |
833 |
833 |
resp.forms[0]['label'] = 'foobar'
|
834 |
834 |
resp.forms[0]['type'] = 'Text (line)'
|
835 |
835 |
resp = resp.forms[0].submit()
|
836 |
|
assert resp.location == 'http://example.net/admin/workflows/1/variables/fields/'
|
|
836 |
assert resp.location == 'http://example.net/backoffice/workflows/1/variables/fields/'
|
837 |
837 |
resp = resp.follow()
|
838 |
838 |
|
839 |
839 |
# check it's been saved correctly
|
... | ... | |
846 |
846 |
test_workflows_variables()
|
847 |
847 |
|
848 |
848 |
app = login(get_app(pub))
|
849 |
|
resp = app.get('/admin/workflows/1/')
|
|
849 |
resp = app.get('/backoffice/workflows/1/')
|
850 |
850 |
resp = resp.click(href='variables/')
|
851 |
|
assert resp.location == 'http://example.net/admin/workflows/1/variables/fields/'
|
|
851 |
assert resp.location == 'http://example.net/backoffice/workflows/1/variables/fields/'
|
852 |
852 |
resp = resp.follow()
|
853 |
853 |
resp = resp.click('Edit', href='1/')
|
854 |
854 |
assert resp.forms[0]['varname$name'].value == 'foobar'
|
... | ... | |
861 |
861 |
baz_status.items.append(display_message)
|
862 |
862 |
workflow.store()
|
863 |
863 |
|
864 |
|
resp = app.get('/admin/workflows/1/variables/fields/')
|
|
864 |
resp = app.get('/backoffice/workflows/1/variables/fields/')
|
865 |
865 |
resp = resp.click('Edit', href='1/')
|
866 |
866 |
assert 'varname$select' in resp.forms[0].fields
|
867 |
867 |
resp.forms[0]['varname$select'].value = '1*1*message'
|
... | ... | |
873 |
873 |
def test_users():
|
874 |
874 |
create_superuser()
|
875 |
875 |
app = login(get_app(pub))
|
876 |
|
app.get('/admin/users/')
|
|
876 |
app.get('/backoffice/users/')
|
877 |
877 |
|
878 |
878 |
def test_users_new():
|
879 |
879 |
pub.user_class.wipe()
|
... | ... | |
881 |
881 |
user_count = pub.user_class.count()
|
882 |
882 |
account_count = PasswordAccount.count()
|
883 |
883 |
app = login(get_app(pub))
|
884 |
|
resp = app.get('/admin/users/')
|
|
884 |
resp = app.get('/backoffice/users/')
|
885 |
885 |
resp = resp.click('New User')
|
886 |
886 |
resp.forms[0]['name'] = 'a new user'
|
887 |
887 |
resp = resp.forms[0].submit('submit')
|
888 |
|
assert resp.location == 'http://example.net/admin/users/'
|
|
888 |
assert resp.location == 'http://example.net/backoffice/users/'
|
889 |
889 |
resp = resp.follow()
|
890 |
890 |
assert 'a new user' in resp.body
|
891 |
891 |
resp = resp.click('a new user')
|
... | ... | |
899 |
899 |
user_count = pub.user_class.count()
|
900 |
900 |
account_count = PasswordAccount.count()
|
901 |
901 |
app = login(get_app(pub))
|
902 |
|
resp = app.get('/admin/users/')
|
|
902 |
resp = app.get('/backoffice/users/')
|
903 |
903 |
resp = resp.click('New User')
|
904 |
904 |
resp.forms[0]['name'] = 'a second user'
|
905 |
905 |
resp.forms[0]['method_password$username'] = 'second-user'
|
906 |
906 |
resp.forms[0]['method_password$password'] = 'foobar'
|
907 |
907 |
resp = resp.forms[0].submit('submit')
|
908 |
|
assert resp.location == 'http://example.net/admin/users/'
|
|
908 |
assert resp.location == 'http://example.net/backoffice/users/'
|
909 |
909 |
resp = resp.follow()
|
910 |
910 |
assert 'a second user' in resp.body
|
911 |
911 |
resp = resp.click('a second user')
|
... | ... | |
921 |
921 |
assert user.id == 2
|
922 |
922 |
|
923 |
923 |
app = login(get_app(pub))
|
924 |
|
resp = app.get('/admin/users/2/')
|
|
924 |
resp = app.get('/backoffice/users/2/')
|
925 |
925 |
resp = resp.click(href='edit')
|
926 |
926 |
resp.forms[0]['is_admin'].checked = True
|
927 |
927 |
resp = resp.forms[0].submit('submit')
|
928 |
|
assert resp.location == 'http://example.net/admin/users/2/'
|
|
928 |
assert resp.location == 'http://example.net/backoffice/users/2/'
|
929 |
929 |
resp = resp.follow()
|
930 |
930 |
|
931 |
931 |
def test_users_edit_new_account():
|
... | ... | |
938 |
938 |
account_count = PasswordAccount.count()
|
939 |
939 |
|
940 |
940 |
app = login(get_app(pub))
|
941 |
|
resp = app.get('/admin/users/2/')
|
|
941 |
resp = app.get('/backoffice/users/2/')
|
942 |
942 |
resp = resp.click(href='edit')
|
943 |
943 |
resp.forms[0]['is_admin'].checked = True
|
944 |
944 |
resp.forms[0]['method_password$username'] = 'foo'
|
945 |
945 |
resp.forms[0]['method_password$password'] = 'bar'
|
946 |
946 |
resp = resp.forms[0].submit('submit')
|
947 |
|
assert resp.location == 'http://example.net/admin/users/2/'
|
|
947 |
assert resp.location == 'http://example.net/backoffice/users/2/'
|
948 |
948 |
resp = resp.follow()
|
949 |
949 |
|
950 |
950 |
assert PasswordAccount.count() == account_count + 1
|
... | ... | |
961 |
961 |
assert PasswordAccount.has_key('test')
|
962 |
962 |
|
963 |
963 |
app = login(get_app(pub))
|
964 |
|
resp = app.get('/admin/users/2/')
|
|
964 |
resp = app.get('/backoffice/users/2/')
|
965 |
965 |
resp = resp.click(href='edit')
|
966 |
966 |
resp.forms[0]['is_admin'].checked = True
|
967 |
967 |
resp.forms[0]['method_password$username'] = 'foo' # change username
|
968 |
968 |
resp.forms[0]['method_password$password'] = 'bar'
|
969 |
969 |
resp = resp.forms[0].submit('submit')
|
970 |
|
assert resp.location == 'http://example.net/admin/users/2/'
|
|
970 |
assert resp.location == 'http://example.net/backoffice/users/2/'
|
971 |
971 |
resp = resp.follow()
|
972 |
972 |
|
973 |
973 |
# makes sure the old account has been removed
|
... | ... | |
989 |
989 |
account_count = PasswordAccount.count()
|
990 |
990 |
|
991 |
991 |
app = login(get_app(pub))
|
992 |
|
resp = app.get('/admin/users/2/')
|
|
992 |
resp = app.get('/backoffice/users/2/')
|
993 |
993 |
|
994 |
994 |
resp = resp.click(href='delete')
|
995 |
995 |
resp = resp.forms[0].submit()
|
996 |
|
assert resp.location == 'http://example.net/admin/users/'
|
|
996 |
assert resp.location == 'http://example.net/backoffice/users/'
|
997 |
997 |
resp = resp.follow()
|
998 |
998 |
|
999 |
999 |
assert pub.user_class.count() == user_count - 1
|
... | ... | |
1008 |
1008 |
user.store()
|
1009 |
1009 |
|
1010 |
1010 |
app = login(get_app(pub))
|
1011 |
|
resp = app.get('/admin/users/')
|
|
1011 |
resp = app.get('/backoffice/users/')
|
1012 |
1012 |
assert 'foo bar 10' in resp.body
|
1013 |
1013 |
assert 'foo bar 30' not in resp.body
|
1014 |
1014 |
|
... | ... | |
1039 |
1039 |
user.store()
|
1040 |
1040 |
|
1041 |
1041 |
app = login(get_app(pub))
|
1042 |
|
resp = app.get('/admin/users/')
|
|
1042 |
resp = app.get('/backoffice/users/')
|
1043 |
1043 |
assert 'admin' in resp.body # superuser
|
1044 |
1044 |
assert 'foo bar 10' in resp.body # simple user
|
1045 |
1045 |
|
... | ... | |
1047 |
1047 |
# resp.forms[0].fields['role'][-1].checked = False
|
1048 |
1048 |
# resp = resp.forms[0].submit()
|
1049 |
1049 |
# therefore we fall back on using the URL
|
1050 |
|
resp = app.get('/admin/users/?offset=0&limit=100&q=&filter=true&role=admin')
|
|
1050 |
resp = app.get('/backoffice/users/?offset=0&limit=100&q=&filter=true&role=admin')
|
1051 |
1051 |
assert '>Number of filtered users: 1<' in resp.body
|
1052 |
1052 |
assert 'user-is-admin' in resp.body # superuser
|
1053 |
1053 |
assert 'foo bar 1' not in resp.body # simple user
|
1054 |
1054 |
assert 'baz bar 1' not in resp.body # user with role
|
1055 |
1055 |
|
1056 |
|
resp = app.get('/admin/users/?offset=0&limit=100&q=&filter=true&role=1')
|
|
1056 |
resp = app.get('/backoffice/users/?offset=0&limit=100&q=&filter=true&role=1')
|
1057 |
1057 |
assert '>Number of filtered users: 5<' in resp.body
|
1058 |
1058 |
assert 'user-is-admin' not in resp.body # superuser
|
1059 |
1059 |
assert 'foo bar 10' not in resp.body # simple user
|
... | ... | |
1071 |
1071 |
user.store()
|
1072 |
1072 |
|
1073 |
1073 |
app = login(get_app(pub))
|
1074 |
|
resp = app.get('/admin/users/')
|
|
1074 |
resp = app.get('/backoffice/users/')
|
1075 |
1075 |
assert 'foo 10' in resp.body
|
1076 |
1076 |
|
1077 |
1077 |
resp.forms[0]['q'] = 'bar'
|
... | ... | |
1082 |
1082 |
|
1083 |
1083 |
def test_roles():
|
1084 |
1084 |
app = login(get_app(pub))
|
1085 |
|
app.get('/admin/roles/')
|
|
1085 |
app.get('/backoffice/roles/')
|
1086 |
1086 |
|
1087 |
1087 |
def test_roles_new():
|
1088 |
1088 |
Role.wipe()
|
1089 |
1089 |
app = login(get_app(pub))
|
1090 |
|
resp = app.get('/admin/roles/')
|
|
1090 |
resp = app.get('/backoffice/roles/')
|
1091 |
1091 |
resp = resp.click('New Role')
|
1092 |
1092 |
resp.forms[0]['name'] = 'a new role'
|
1093 |
1093 |
resp.forms[0]['details'] = 'bla bla bla'
|
1094 |
1094 |
resp = resp.forms[0].submit('submit')
|
1095 |
|
assert resp.location == 'http://example.net/admin/roles/'
|
|
1095 |
assert resp.location == 'http://example.net/backoffice/roles/'
|
1096 |
1096 |
resp = resp.follow()
|
1097 |
1097 |
assert 'a new role' in resp.body
|
1098 |
1098 |
resp = resp.click('a new role')
|
... | ... | |
1107 |
1107 |
role.store()
|
1108 |
1108 |
|
1109 |
1109 |
app = login(get_app(pub))
|
1110 |
|
resp = app.get('/admin/roles/1/')
|
|
1110 |
resp = app.get('/backoffice/roles/1/')
|
1111 |
1111 |
assert 'Holders of this role are granted access to the backoffice' in resp.body
|
1112 |
1112 |
|
1113 |
1113 |
resp = resp.click(href='edit')
|
... | ... | |
1116 |
1116 |
resp.forms[0]['details'] = 'bla bla bla'
|
1117 |
1117 |
resp.forms[0]['emails_to_members'].checked = True
|
1118 |
1118 |
resp = resp.forms[0].submit('submit')
|
1119 |
|
assert resp.location == 'http://example.net/admin/roles/1/'
|
|
1119 |
assert resp.location == 'http://example.net/backoffice/roles/1/'
|
1120 |
1120 |
resp = resp.follow()
|
1121 |
1121 |
assert 'Role - baz' in resp.body
|
1122 |
1122 |
assert 'Holders of this role will receive all emails adressed to the role.' in resp.body
|
... | ... | |
1131 |
1131 |
|
1132 |
1132 |
FormDef.wipe()
|
1133 |
1133 |
app = login(get_app(pub))
|
1134 |
|
resp = app.get('/admin/roles/1/')
|
|
1134 |
resp = app.get('/backoffice/roles/1/')
|
1135 |
1135 |
assert 'form bar' not in resp.body
|
1136 |
1136 |
|
1137 |
1137 |
formdef = FormDef()
|
... | ... | |
1139 |
1139 |
formdef.roles = [role.id]
|
1140 |
1140 |
formdef.store()
|
1141 |
1141 |
|
1142 |
|
resp = app.get('/admin/roles/1/')
|
|
1142 |
resp = app.get('/backoffice/roles/1/')
|
1143 |
1143 |
assert 'form bar' in resp.body
|
1144 |
1144 |
assert 'form baz' not in resp.body
|
1145 |
1145 |
|
... | ... | |
1149 |
1149 |
formdef.workflow_roles = {'_receiver': role.id}
|
1150 |
1150 |
formdef.store()
|
1151 |
1151 |
|
1152 |
|
resp = app.get('/admin/roles/1/')
|
|
1152 |
resp = app.get('/backoffice/roles/1/')
|
1153 |
1153 |
assert 'form baz' in resp.body
|
1154 |
1154 |
assert 'form bar' not in resp.body
|
1155 |
1155 |
|
... | ... | |
1159 |
1159 |
role.store()
|
1160 |
1160 |
|
1161 |
1161 |
app = login(get_app(pub))
|
1162 |
|
resp = app.get('/admin/roles/1/')
|
|
1162 |
resp = app.get('/backoffice/roles/1/')
|
1163 |
1163 |
|
1164 |
1164 |
resp = resp.click(href='delete')
|
1165 |
1165 |
resp = resp.forms[0].submit()
|
1166 |
|
assert resp.location == 'http://example.net/admin/roles/'
|
|
1166 |
assert resp.location == 'http://example.net/backoffice/roles/'
|
1167 |
1167 |
resp = resp.follow()
|
1168 |
1168 |
assert Role.count() == 0
|
1169 |
1169 |
|
1170 |
1170 |
def test_categories():
|
1171 |
1171 |
app = login(get_app(pub))
|
1172 |
|
app.get('/admin/categories/')
|
|
1172 |
app.get('/backoffice/categories/')
|
1173 |
1173 |
|
1174 |
1174 |
def test_categories_new():
|
1175 |
1175 |
Category.wipe()
|
1176 |
1176 |
app = login(get_app(pub))
|
1177 |
1177 |
|
1178 |
1178 |
# go to the page and cancel
|
1179 |
|
resp = app.get('/admin/categories/')
|
|
1179 |
resp = app.get('/backoffice/categories/')
|
1180 |
1180 |
resp = resp.click('New Category')
|
1181 |
1181 |
resp = resp.forms[0].submit('cancel')
|
1182 |
|
assert resp.location == 'http://example.net/admin/categories/'
|
|
1182 |
assert resp.location == 'http://example.net/backoffice/categories/'
|
1183 |
1183 |
|
1184 |
1184 |
# go to the page and add a category
|
1185 |
|
resp = app.get('/admin/categories/')
|
|
1185 |
resp = app.get('/backoffice/categories/')
|
1186 |
1186 |
resp = resp.click('New Category')
|
1187 |
1187 |
resp.forms[0]['name'] = 'a new category'
|
1188 |
1188 |
resp.forms[0]['description'] = 'description of the category'
|
1189 |
1189 |
resp = resp.forms[0].submit('submit')
|
1190 |
|
assert resp.location == 'http://example.net/admin/categories/'
|
|
1190 |
assert resp.location == 'http://example.net/backoffice/categories/'
|
1191 |
1191 |
resp = resp.follow()
|
1192 |
1192 |
assert 'a new category' in resp.body
|
1193 |
1193 |
resp = resp.click('a new category')
|
... | ... | |
1202 |
1202 |
category.store()
|
1203 |
1203 |
|
1204 |
1204 |
app = login(get_app(pub))
|
1205 |
|
resp = app.get('/admin/categories/1/')
|
|
1205 |
resp = app.get('/backoffice/categories/1/')
|
1206 |
1206 |
assert 'no form associated to this category' in resp.body
|
1207 |
1207 |
|
1208 |
1208 |
resp = resp.click(href='edit')
|
1209 |
1209 |
assert resp.forms[0]['name'].value == 'foobar'
|
1210 |
1210 |
resp.forms[0]['description'] = 'category description'
|
1211 |
1211 |
resp = resp.forms[0].submit('submit')
|
1212 |
|
assert resp.location == 'http://example.net/admin/categories/'
|
|
1212 |
assert resp.location == 'http://example.net/backoffice/categories/'
|
1213 |
1213 |
resp = resp.follow()
|
1214 |
1214 |
resp = resp.click('foobar')
|
1215 |
1215 |
assert 'Category - foobar' in resp.body
|
... | ... | |
1224 |
1224 |
category.store()
|
1225 |
1225 |
|
1226 |
1226 |
app = login(get_app(pub))
|
1227 |
|
resp = app.get('/admin/categories/1/')
|
|
1227 |
resp = app.get('/backoffice/categories/1/')
|
1228 |
1228 |
|
1229 |
1229 |
resp = resp.click(href='edit')
|
1230 |
1230 |
assert resp.forms[0]['name'].value == 'foobar'
|
... | ... | |
1233 |
1233 |
assert 'This name is already used' in resp.body
|
1234 |
1234 |
|
1235 |
1235 |
resp = resp.forms[0].submit('cancel')
|
1236 |
|
assert resp.location == 'http://example.net/admin/categories/'
|
|
1236 |
assert resp.location == 'http://example.net/backoffice/categories/'
|
1237 |
1237 |
|
1238 |
1238 |
def test_categories_with_formdefs():
|
1239 |
1239 |
Category.wipe()
|
... | ... | |
1242 |
1242 |
|
1243 |
1243 |
FormDef.wipe()
|
1244 |
1244 |
app = login(get_app(pub))
|
1245 |
|
resp = app.get('/admin/categories/1/')
|
|
1245 |
resp = app.get('/backoffice/categories/1/')
|
1246 |
1246 |
assert 'form bar' not in resp.body
|
1247 |
1247 |
|
1248 |
1248 |
formdef = FormDef()
|
... | ... | |
1250 |
1250 |
formdef.category_id = category.id
|
1251 |
1251 |
formdef.store()
|
1252 |
1252 |
|
1253 |
|
resp = app.get('/admin/categories/1/')
|
|
1253 |
resp = app.get('/backoffice/categories/1/')
|
1254 |
1254 |
assert 'form bar' in resp.body
|
1255 |
1255 |
assert 'no form associated to this category' not in resp.body
|
1256 |
1256 |
|
... | ... | |
1261 |
1261 |
|
1262 |
1262 |
FormDef.wipe()
|
1263 |
1263 |
app = login(get_app(pub))
|
1264 |
|
resp = app.get('/admin/categories/1/')
|
|
1264 |
resp = app.get('/backoffice/categories/1/')
|
1265 |
1265 |
|
1266 |
1266 |
resp = resp.click(href='delete')
|
1267 |
1267 |
resp = resp.forms[0].submit('cancel')
|
1268 |
|
assert resp.location == 'http://example.net/admin/categories/'
|
|
1268 |
assert resp.location == 'http://example.net/backoffice/categories/'
|
1269 |
1269 |
assert Category.count() == 1
|
1270 |
1270 |
|
1271 |
|
resp = app.get('/admin/categories/1/')
|
|
1271 |
resp = app.get('/backoffice/categories/1/')
|
1272 |
1272 |
resp = resp.click(href='delete')
|
1273 |
1273 |
resp = resp.forms[0].submit()
|
1274 |
|
assert resp.location == 'http://example.net/admin/categories/'
|
|
1274 |
assert resp.location == 'http://example.net/backoffice/categories/'
|
1275 |
1275 |
resp = resp.follow()
|
1276 |
1276 |
assert Category.count() == 0
|
1277 |
1277 |
|
... | ... | |
1285 |
1285 |
app = login(get_app(pub))
|
1286 |
1286 |
# this URL is used for editing from the frontoffice, there's no link
|
1287 |
1287 |
# pointing to it in the admin.
|
1288 |
|
resp = app.get('/admin/categories/1/description')
|
|
1288 |
resp = app.get('/backoffice/categories/1/description')
|
1289 |
1289 |
assert resp.forms[0]['description'].value == 'category description'
|
1290 |
1290 |
resp.forms[0]['description'] = 'updated description'
|
1291 |
1291 |
|
1292 |
1292 |
# check cancel doesn't save the change
|
1293 |
1293 |
resp2 = resp.forms[0].submit('cancel')
|
1294 |
|
assert resp2.location == 'http://example.net/admin/categories/1/'
|
|
1294 |
assert resp2.location == 'http://example.net/backoffice/categories/1/'
|
1295 |
1295 |
assert Category.get(1).description == 'category description'
|
1296 |
1296 |
|
1297 |
1297 |
# check submit does it properly
|
1298 |
1298 |
resp2 = resp.forms[0].submit('submit')
|
1299 |
|
assert resp2.location == 'http://example.net/admin/categories/1/'
|
|
1299 |
assert resp2.location == 'http://example.net/backoffice/categories/1/'
|
1300 |
1300 |
resp2 = resp2.follow()
|
1301 |
1301 |
assert Category.get(1).description == 'updated description'
|
1302 |
1302 |
|
... | ... | |
1306 |
1306 |
category.store()
|
1307 |
1307 |
|
1308 |
1308 |
app = login(get_app(pub))
|
1309 |
|
resp = app.get('/admin/categories/')
|
|
1309 |
resp = app.get('/backoffice/categories/')
|
1310 |
1310 |
resp = resp.click('New Category')
|
1311 |
1311 |
resp.forms[0]['name'] = 'foobar'
|
1312 |
1312 |
resp = resp.forms[0].submit('submit')
|
... | ... | |
1322 |
1322 |
category.store()
|
1323 |
1323 |
|
1324 |
1324 |
app = login(get_app(pub))
|
1325 |
|
resp = app.get('/admin/categories/update_order?order=1;2;3;')
|
|
1325 |
resp = app.get('/backoffice/categories/update_order?order=1;2;3;')
|
1326 |
1326 |
categories = Category.select()
|
1327 |
1327 |
Category.sort_by_position(categories)
|
1328 |
1328 |
assert [x.id for x in categories] == [1, 2, 3]
|
1329 |
1329 |
|
1330 |
|
resp = app.get('/admin/categories/update_order?order=3;1;2;')
|
|
1330 |
resp = app.get('/backoffice/categories/update_order?order=3;1;2;')
|
1331 |
1331 |
categories = Category.select()
|
1332 |
1332 |
Category.sort_by_position(categories)
|
1333 |
1333 |
assert [x.id for x in categories] == [3, 1, 2]
|
1334 |
1334 |
|
1335 |
1335 |
def test_settings():
|
1336 |
1336 |
app = login(get_app(pub))
|
1337 |
|
app.get('/admin/settings/')
|
|
1337 |
app.get('/backoffice/settings/')
|
1338 |
1338 |
|
1339 |
|
app.get('/admin/settings/misc')
|
1340 |
|
app.get('/admin/settings/debug_options')
|
1341 |
|
app.get('/admin/settings/language')
|
1342 |
|
app.get('/admin/settings/import')
|
1343 |
|
app.get('/admin/settings/export')
|
1344 |
|
app.get('/admin/settings/identification')
|
1345 |
|
app.get('/admin/settings/sitename')
|
1346 |
|
app.get('/admin/settings/sms')
|
1347 |
|
app.get('/admin/settings/session')
|
1348 |
|
app.get('/admin/settings/admin-permissions')
|
|
1339 |
app.get('/backoffice/settings/misc')
|
|
1340 |
app.get('/backoffice/settings/debug_options')
|
|
1341 |
app.get('/backoffice/settings/language')
|
|
1342 |
app.get('/backoffice/settings/import')
|
|
1343 |
app.get('/backoffice/settings/export')
|
|
1344 |
app.get('/backoffice/settings/identification')
|
|
1345 |
app.get('/backoffice/settings/sitename')
|
|
1346 |
app.get('/backoffice/settings/sms')
|
|
1347 |
app.get('/backoffice/settings/session')
|
|
1348 |
app.get('/backoffice/settings/admin-permissions')
|
1349 |
1349 |
|
1350 |
1350 |
|
1351 |
1351 |
def test_settings_themes():
|
... | ... | |
1362 |
1362 |
'</theme>')
|
1363 |
1363 |
fd.close()
|
1364 |
1364 |
|
1365 |
|
resp = app.get('/admin/settings/themes')
|
|
1365 |
resp = app.get('/backoffice/settings/themes')
|
1366 |
1366 |
assert 'biglist themes' in resp.body
|
1367 |
1367 |
assert 'Test Theme (1.0)' in resp.body
|
1368 |
1368 |
|
1369 |
1369 |
# just for the kick, there's no support for uploading file in webtest 1.3
|
1370 |
|
resp = app.get('/admin/settings/themes')
|
|
1370 |
resp = app.get('/backoffice/settings/themes')
|
1371 |
1371 |
resp.click('Install New Theme')
|
1372 |
1372 |
|
1373 |
1373 |
# select the theme
|
1374 |
|
resp = app.get('/admin/settings/themes')
|
|
1374 |
resp = app.get('/backoffice/settings/themes')
|
1375 |
1375 |
resp.forms[0]['theme'].value = 'test'
|
1376 |
1376 |
resp = resp.forms[0].submit()
|
1377 |
|
assert resp.location == 'http://example.net/admin/settings/'
|
|
1377 |
assert resp.location == 'http://example.net/backoffice/settings/'
|
1378 |
1378 |
|
1379 |
|
resp = app.get('/admin/settings/themes')
|
|
1379 |
resp = app.get('/backoffice/settings/themes')
|
1380 |
1380 |
assert 'checked' in resp.body
|
1381 |
1381 |
assert get_current_theme()['name'] == 'test'
|
1382 |
1382 |
|
1383 |
1383 |
def test_settings_template():
|
1384 |
1384 |
create_superuser()
|
1385 |
1385 |
app = login(get_app(pub))
|
1386 |
|
resp = app.get('/admin/settings/template')
|
|
1386 |
resp = app.get('/backoffice/settings/template')
|
1387 |
1387 |
|
1388 |
1388 |
# change template
|
1389 |
1389 |
orig_value = resp.forms[0]['template'].value
|
... | ... | |
1392 |
1392 |
resp = resp.forms[0].submit('submit')
|
1393 |
1393 |
|
1394 |
1394 |
# restore default template
|
1395 |
|
resp = app.get('/admin/settings/template')
|
|
1395 |
resp = app.get('/backoffice/settings/template')
|
1396 |
1396 |
assert 'foobar' in resp.forms[0]['template'].value
|
1397 |
1397 |
resp = resp.forms[0].submit('restore-default')
|
1398 |
1398 |
|
1399 |
1399 |
# check
|
1400 |
|
resp = app.get('/admin/settings/template')
|
|
1400 |
resp = app.get('/backoffice/settings/template')
|
1401 |
1401 |
assert resp.forms[0]['template'].value == orig_value
|
1402 |
1402 |
|
1403 |
1403 |
def test_settings_user():
|
1404 |
1404 |
create_superuser()
|
1405 |
1405 |
app = login(get_app(pub))
|
1406 |
|
resp = app.get('/admin/settings/users').follow().follow()
|
|
1406 |
resp = app.get('/backoffice/settings/users').follow().follow()
|
1407 |
1407 |
|
1408 |
1408 |
# add a field
|
1409 |
1409 |
resp.forms[1]['label'] = 'foobar'
|
1410 |
1410 |
resp = resp.forms[1].submit()
|
1411 |
|
assert resp.location == 'http://example.net/admin/settings/users/fields/'
|
|
1411 |
assert resp.location == 'http://example.net/backoffice/settings/users/fields/'
|
1412 |
1412 |
resp = resp.follow()
|
1413 |
1413 |
assert 'foobar' in pub.cfg['users']['formdef']
|
1414 |
1414 |
assert 'foobar' in resp.body
|
... | ... | |
1416 |
1416 |
# set field as email
|
1417 |
1417 |
resp.forms[0]['field_email'] = '1'
|
1418 |
1418 |
resp = resp.forms[0].submit()
|
1419 |
|
assert resp.location == 'http://example.net/admin/settings/users/fields/'
|
|
1419 |
assert resp.location == 'http://example.net/backoffice/settings/users/fields/'
|
1420 |
1420 |
resp = resp.follow()
|
1421 |
1421 |
assert pub.cfg['users']['field_email'] == '1'
|
1422 |
1422 |
|
1423 |
1423 |
# and unset it
|
1424 |
1424 |
resp.forms[0]['field_email'] = ''
|
1425 |
1425 |
resp = resp.forms[0].submit()
|
1426 |
|
assert resp.location == 'http://example.net/admin/settings/users/fields/'
|
|
1426 |
assert resp.location == 'http://example.net/backoffice/settings/users/fields/'
|
1427 |
1427 |
resp = resp.follow()
|
1428 |
1428 |
assert pub.cfg['users']['field_email'] == None
|
1429 |
1429 |
|
... | ... | |
1431 |
1431 |
resp.forms[1]['label'] = 'barfoo'
|
1432 |
1432 |
resp.forms[1]['type'] = 'Comment'
|
1433 |
1433 |
resp = resp.forms[1].submit()
|
1434 |
|
assert resp.location == 'http://example.net/admin/settings/users/fields/'
|
|
1434 |
assert resp.location == 'http://example.net/backoffice/settings/users/fields/'
|
1435 |
1435 |
resp = resp.follow()
|
1436 |
1436 |
assert 'barfoo' in pub.cfg['users']['formdef']
|
1437 |
1437 |
assert 'barfoo' in resp.body
|
1438 |
1438 |
|
1439 |
1439 |
# check fields are present in edit form
|
1440 |
|
resp = app.get('/admin/users/admin/edit')
|
|
1440 |
resp = app.get('/backoffice/users/admin/edit')
|
1441 |
1441 |
assert 'barfoo' in resp.body
|
1442 |
1442 |
assert 'f1' in resp.forms[0].fields
|
1443 |
1443 |
assert 'email' in resp.forms[0].fields
|
... | ... | |
1446 |
1446 |
# field.
|
1447 |
1447 |
pub.cfg['users']['field_email'] = '1'
|
1448 |
1448 |
pub.write_cfg()
|
1449 |
|
resp = app.get('/admin/users/admin/edit')
|
|
1449 |
resp = app.get('/backoffice/users/admin/edit')
|
1450 |
1450 |
assert 'f1' in resp.forms[0].fields
|
1451 |
1451 |
assert 'email' not in resp.forms[0].fields
|
1452 |
1452 |
|
... | ... | |
1460 |
1460 |
|
1461 |
1461 |
pub.cfg['debug'] = {'mail_redirection': 'foo@example.net'}
|
1462 |
1462 |
pub.write_cfg()
|
1463 |
|
resp = app.get('/admin/settings/emails/')
|
|
1463 |
resp = app.get('/backoffice/settings/emails/')
|
1464 |
1464 |
resp = resp.click('General Options')
|
1465 |
1465 |
assert 'Warning: all emails are sent to <foo@example.net>' in resp.body
|
1466 |
1466 |
|
1467 |
1467 |
pub.cfg['debug'] = {}
|
1468 |
1468 |
pub.write_cfg()
|
1469 |
|
resp = app.get('/admin/settings/emails/')
|
|
1469 |
resp = app.get('/backoffice/settings/emails/')
|
1470 |
1470 |
resp = resp.click('General Options')
|
1471 |
1471 |
assert 'Warning: all emails are sent to <foo@example.net>' not in resp.body
|
1472 |
1472 |
|
1473 |
|
resp = app.get('/admin/settings/emails/')
|
|
1473 |
resp = app.get('/backoffice/settings/emails/')
|
1474 |
1474 |
resp = resp.click('Approval of new account')
|
1475 |
1475 |
resp.forms[0]['email-new-account-approved_subject'] = 'bla'
|
1476 |
1476 |
resp.forms[0]['email-new-account-approved'] = 'bla bla bla'
|
... | ... | |
1479 |
1479 |
assert pub.cfg['emails']['email-new-account-approved'] == 'bla bla bla'
|
1480 |
1480 |
|
1481 |
1481 |
# reset to default value
|
1482 |
|
resp = app.get('/admin/settings/emails/')
|
|
1482 |
resp = app.get('/backoffice/settings/emails/')
|
1483 |
1483 |
resp = resp.click('Approval of new account')
|
1484 |
1484 |
resp.forms[0]['email-new-account-approved_subject'] = 'Your account has been approved'
|
1485 |
1485 |
resp = resp.forms[0].submit()
|
... | ... | |
1489 |
1489 |
create_superuser()
|
1490 |
1490 |
app = login(get_app(pub))
|
1491 |
1491 |
|
1492 |
|
resp = app.get('/admin/settings/texts/')
|
|
1492 |
resp = app.get('/backoffice/settings/texts/')
|
1493 |
1493 |
resp = resp.click('Text on top of the login page')
|
1494 |
1494 |
resp.forms[0]['text-top-of-login'] = 'Hello world'
|
1495 |
1495 |
resp = resp.forms[0].submit()
|
1496 |
|
assert resp.location == 'http://example.net/admin/settings/texts/'
|
|
1496 |
assert resp.location == 'http://example.net/backoffice/settings/texts/'
|
1497 |
1497 |
assert pub.cfg['texts']['text-top-of-login'] == 'Hello world'
|
1498 |
1498 |
|
1499 |
|
resp = app.get('/admin/settings/texts/')
|
|
1499 |
resp = app.get('/backoffice/settings/texts/')
|
1500 |
1500 |
resp = resp.click('Text on top of the login page')
|
1501 |
1501 |
resp = resp.forms[0].submit('restore-default')
|
1502 |
|
assert resp.location == 'http://example.net/admin/settings/texts/'
|
|
1502 |
assert resp.location == 'http://example.net/backoffice/settings/texts/'
|
1503 |
1503 |
assert pub.cfg['texts']['text-top-of-login'] == None
|
1504 |
1504 |
|
1505 |
1505 |
@pytest.mark.skipif('lasso is None')
|
... | ... | |
1509 |
1509 |
pub.write_cfg()
|
1510 |
1510 |
app = get_app(pub)
|
1511 |
1511 |
|
1512 |
|
resp = app.get('/admin/settings/')
|
|
1512 |
resp = app.get('/backoffice/settings/')
|
1513 |
1513 |
assert not 'identification/password/' in resp.body
|
1514 |
1514 |
assert not 'identification/idp/' in resp.body
|
1515 |
1515 |
|
... | ... | |
1539 |
1539 |
pub.write_cfg()
|
1540 |
1540 |
app = get_app(pub)
|
1541 |
1541 |
app.get('/saml/metadata', status=404)
|
1542 |
|
resp = app.get('/admin/settings/')
|
|
1542 |
resp = app.get('/backoffice/settings/')
|
1543 |
1543 |
resp = resp.click(href='identification/idp/')
|
1544 |
1544 |
resp = resp.click('Service Provider')
|
1545 |
1545 |
resp = resp.forms[0].submit()
|
... | ... | |
1564 |
1564 |
login_resp = app.get('/login/', status=302)
|
1565 |
1565 |
assert login_resp.location.startswith('http://sso.example.net/saml2/sso?SAMLRequest')
|
1566 |
1566 |
|
1567 |
|
resp = resp.click(href='/admin/settings/identification/idp/idp/') # breadcrumb
|
|
1567 |
resp = resp.click(href='/backoffice/settings/identification/idp/idp/') # breadcrumb
|
1568 |
1568 |
resp = resp.click(href='http-sso.example.net-saml2-metadata/delete')
|
1569 |
1569 |
resp = resp.forms[0].submit() # confirm delete
|
1570 |
1570 |
assert len(pub.cfg['idp']) == 0
|
... | ... | |
1573 |
1573 |
create_superuser()
|
1574 |
1574 |
app = login(get_app(pub))
|
1575 |
1575 |
|
1576 |
|
resp = app.get('/admin/settings/filetypes/')
|
|
1576 |
resp = app.get('/backoffice/settings/filetypes/')
|
1577 |
1577 |
assert 'There are no file type defined at the moment.' in resp.body
|
1578 |
1578 |
resp.forms[0]['label'] = 'Text files'
|
1579 |
1579 |
resp.forms[0]['mimetypes'] = '.odt'
|
1580 |
1580 |
resp = resp.forms[0].submit('submit')
|
1581 |
|
assert resp.location == 'http://example.net/admin/settings/filetypes/'
|
|
1581 |
assert resp.location == 'http://example.net/backoffice/settings/filetypes/'
|
1582 |
1582 |
resp = resp.follow()
|
1583 |
1583 |
assert pub.cfg['filetypes'][1]['label'] == 'Text files'
|
1584 |
1584 |
|
... | ... | |
1586 |
1586 |
assert resp.forms[0]['mimetypes'].value == 'application/vnd.oasis.opendocument.text'
|
1587 |
1587 |
resp.forms[0]['mimetypes'] = 'application/vnd.oasis.opendocument.text, .doc, .docx, .pdf'
|
1588 |
1588 |
resp = resp.forms[0].submit('submit')
|
1589 |
|
assert resp.location == 'http://example.net/admin/settings/filetypes/'
|
|
1589 |
assert resp.location == 'http://example.net/backoffice/settings/filetypes/'
|
1590 |
1590 |
resp = resp.follow()
|
1591 |
1591 |
assert 'application/msword (.doc)' in resp.body
|
1592 |
1592 |
assert 'application/pdf' in pub.cfg['filetypes'][1]['mimetypes']
|
... | ... | |
1597 |
1597 |
resp = resp.follow()
|
1598 |
1598 |
resp = resp.click('HTML files') # go to form
|
1599 |
1599 |
resp = resp.forms[0].submit('cancel') # and cancel
|
1600 |
|
assert resp.location == 'http://example.net/admin/settings/filetypes/'
|
|
1600 |
assert resp.location == 'http://example.net/backoffice/settings/filetypes/'
|
1601 |
1601 |
resp = resp.follow()
|
1602 |
1602 |
assert 'HTML files' in resp.body
|
1603 |
1603 |
|
1604 |
1604 |
resp = resp.click('HTML files') # go to form
|
1605 |
1605 |
resp = resp.forms[0].submit('delete') # and delete
|
1606 |
|
assert resp.location == 'http://example.net/admin/settings/filetypes/'
|
|
1606 |
assert resp.location == 'http://example.net/backoffice/settings/filetypes/'
|
1607 |
1607 |
resp = resp.follow()
|
1608 |
1608 |
assert 'HTML files' not in resp.body
|
1609 |
1609 |
|
... | ... | |
1616 |
1616 |
'label': 'Text files'}
|
1617 |
1617 |
}
|
1618 |
1618 |
pub.write_cfg()
|
1619 |
|
resp = app.get('/admin/settings/filetypes/')
|
|
1619 |
resp = app.get('/backoffice/settings/filetypes/')
|
1620 |
1620 |
assert 'Text files' in resp.body
|
1621 |
1621 |
|
1622 |
1622 |
FormDef.wipe()
|
1623 |
|
-
|