misc: pylint fix astroid-error (#52630)

************* Module tests.admin_pages.test_form
tests/admin_pages/test_form.py:1: [F0002(astroid-error), ]
<class 'RecursionError'>: maximum recursion depth exceeded

split testcase, it seems to fix the error
This commit is contained in:
Lauréline Guérin 2021-04-02 16:27:18 +02:00
parent f79705fa5e
commit 71e5a74898
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
1 changed files with 67 additions and 9 deletions

View File

@ -50,6 +50,16 @@ def teardown_module(module):
clean_temporary_pub()
@pytest.fixture
def formdef(pub):
FormDef.wipe()
formdef = FormDef()
formdef.name = 'form title'
formdef.fields = []
formdef.store()
return formdef
def test_forms(pub):
create_superuser(pub)
pub.role_class.wipe()
@ -114,21 +124,13 @@ def assert_option_display(resp, label, value):
assert '</li>' not in option_line
def test_forms_edit(pub):
def test_forms_edit_confirmation_page(pub, formdef):
create_superuser(pub)
create_role(pub)
FormDef.wipe()
formdef = FormDef()
formdef.name = 'form title'
formdef.fields = []
formdef.store()
app = login(get_app(pub))
resp = app.get('/backoffice/forms/1/')
# try changing an option
# confirmation page
assert_option_display(resp, 'Confirmation Page', 'Enabled')
resp = resp.click('Confirmation Page')
@ -150,6 +152,14 @@ def test_forms_edit(pub):
assert_option_display(resp, 'Confirmation Page', 'Disabled')
assert FormDef.get(1).confirmation is False
def test_forms_edit_limit_one_form(pub, formdef):
create_superuser(pub)
create_role(pub)
app = login(get_app(pub))
resp = app.get('/backoffice/forms/1/')
# Limit to one form
assert_option_display(resp, 'Limit to one form', 'Disabled')
resp = resp.click('Limit to one form')
@ -161,6 +171,14 @@ def test_forms_edit(pub):
assert_option_display(resp, 'Limit to one form', 'Enabled')
assert FormDef.get(1).only_allow_one is True
def test_forms_edit_management(pub, formdef):
create_superuser(pub)
create_role(pub)
app = login(get_app(pub))
resp = app.get('/backoffice/forms/1/')
# Misc management
assert_option_display(resp, 'Management', 'Default')
resp = resp.click('Management', href='options/management')
@ -172,6 +190,14 @@ def test_forms_edit(pub):
assert_option_display(resp, 'Management', 'Custom')
assert FormDef.get(1).include_download_all_button is True
def test_forms_edit_tracking_code(pub, formdef):
create_superuser(pub)
create_role(pub)
app = login(get_app(pub))
resp = app.get('/backoffice/forms/1/')
# Tracking code
assert_option_display(resp, 'Tracking Code', 'Disabled')
resp = resp.click('Tracking Code')
@ -195,6 +221,14 @@ def test_forms_edit(pub):
resp = resp.forms[0].submit().follow()
assert FormDef.get(1).drafts_lifespan == '5'
def test_forms_edit_captcha(pub, formdef):
create_superuser(pub)
create_role(pub)
app = login(get_app(pub))
resp = app.get('/backoffice/forms/1/')
# CAPTCHA
assert_option_display(resp, 'CAPTCHA for anonymous users', 'Disabled')
resp = resp.click('CAPTCHA for anonymous users')
@ -206,6 +240,14 @@ def test_forms_edit(pub):
assert_option_display(resp, 'CAPTCHA for anonymous users', 'Enabled')
assert FormDef.get(1).has_captcha is True
def test_forms_edit_appearance(pub, formdef):
create_superuser(pub)
create_role(pub)
app = login(get_app(pub))
resp = app.get('/backoffice/forms/1/')
# Appearance
assert_option_display(resp, 'Appearance', 'Standard')
resp = resp.click('Appearance')
@ -217,6 +259,14 @@ def test_forms_edit(pub):
assert_option_display(resp, 'Appearance', 'foobar')
assert FormDef.get(1).appearance_keywords == 'foobar'
def test_forms_edit_publication(pub, formdef):
create_superuser(pub)
create_role(pub)
app = login(get_app(pub))
resp = app.get('/backoffice/forms/1/')
# Publication
assert_option_display(resp, 'Online Status', 'Active')
resp = resp.click('Online Status')
@ -246,6 +296,14 @@ def test_forms_edit(pub):
resp = resp.follow()
assert_option_display(resp, 'Online Status', 'Inactive by date')
def test_forms_edit_geolocation(pub, formdef):
create_superuser(pub)
create_role(pub)
app = login(get_app(pub))
resp = app.get('/backoffice/forms/1/')
# enable geolocation
resp = resp.click('Geolocation')
resp.forms[0]['geoloc_label'] = 'Foobar'