tests: remove most manual wiping of logged errors
This commit is contained in:
parent
22e2b58123
commit
91b10ecbda
|
@ -34,8 +34,6 @@ def test_studio_home(pub):
|
|||
|
||||
|
||||
def test_listing_paginations(pub):
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
FormDef.wipe()
|
||||
CardDef.wipe()
|
||||
Workflow.wipe()
|
||||
|
@ -172,8 +170,6 @@ def test_listing_paginations(pub):
|
|||
|
||||
|
||||
def test_backoffice_access(pub):
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
FormDef.wipe()
|
||||
CardDef.wipe()
|
||||
Workflow.wipe()
|
||||
|
@ -261,8 +257,6 @@ def test_backoffice_access(pub):
|
|||
|
||||
|
||||
def test_logged_error_404(pub):
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
create_superuser(pub)
|
||||
app = login(get_app(pub))
|
||||
|
||||
|
|
|
@ -2876,7 +2876,6 @@ def test_workflows_wscall_status_error(pub):
|
|||
|
||||
create_superuser(pub)
|
||||
|
||||
pub.loggederror_class.wipe()
|
||||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
|
|
|
@ -2478,7 +2478,6 @@ def test_backoffice_wscall_on_error(http_requests, pub, emails, notify_on_errors
|
|||
|
||||
create_user(pub)
|
||||
create_environment(pub)
|
||||
pub.loggederror_class.wipe()
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
form_class = formdef.data_class()
|
||||
|
||||
|
@ -2538,7 +2537,6 @@ def test_backoffice_wscall_on_error(http_requests, pub, emails, notify_on_errors
|
|||
# check pub.loggederror_class
|
||||
if record_on_errors:
|
||||
assert pub.loggederror_class.count() == 1
|
||||
pub.loggederror_class.wipe()
|
||||
else:
|
||||
assert pub.loggederror_class.count() == 0
|
||||
|
||||
|
@ -4846,8 +4844,6 @@ def test_backoffice_logged_errors(pub):
|
|||
carddef.fields = []
|
||||
carddef.store()
|
||||
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
create_superuser(pub)
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/forms/%s/' % formdef.id)
|
||||
|
@ -5343,8 +5339,6 @@ def create_formdata(request, pub):
|
|||
source_formdef.store()
|
||||
source_formdef.data_class().wipe()
|
||||
target_formdef.data_class().wipe()
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
return locals()
|
||||
|
||||
|
||||
|
|
|
@ -511,7 +511,6 @@ def test_backoffice_cards_wscall_failure_display(http_requests, pub):
|
|||
pytest.skip('this requires SQL')
|
||||
return
|
||||
|
||||
pub.loggederror_class.wipe()
|
||||
user = create_user(pub)
|
||||
|
||||
Workflow.wipe()
|
||||
|
|
|
@ -5005,9 +5005,6 @@ def test_workflow_condition_on_message(pub):
|
|||
|
||||
|
||||
def test_workflow_message_with_template_error(pub):
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
create_user(pub)
|
||||
|
||||
formdef = create_formdef()
|
||||
|
@ -5041,7 +5038,6 @@ def test_workflow_message_with_template_error(pub):
|
|||
assert pub.loggederror_class.count() == 1
|
||||
logged_error = pub.loggederror_class.select()[0]
|
||||
assert logged_error.summary == "Error in template of workflow message ('int' object is not iterable)"
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
|
||||
def test_session_cookie_flags(pub):
|
||||
|
@ -5668,8 +5664,6 @@ def test_items_field_with_disabled_items(http_requests, pub):
|
|||
|
||||
|
||||
def test_item_field_autocomplete_json_source(http_requests, pub, error_email, emails):
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
create_user(pub)
|
||||
formdef = create_formdef()
|
||||
formdef.data_class().wipe()
|
||||
|
@ -6175,8 +6169,6 @@ def test_logged_errors(pub):
|
|||
formdef.fields = []
|
||||
formdef.store()
|
||||
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
app = get_app(pub)
|
||||
resp = app.get('/test/')
|
||||
resp = resp.form.submit('submit').follow()
|
||||
|
@ -7816,8 +7808,6 @@ def test_create_formdata_anonymous_submitted(create_formdata):
|
|||
|
||||
|
||||
def test_create_formdata_empty_item_ds_with_id_parameter(pub, create_formdata):
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
NamedDataSource.wipe()
|
||||
data_source = NamedDataSource(name='foobar')
|
||||
data_source.data_source = {
|
||||
|
|
|
@ -378,9 +378,6 @@ def test_form_file_field_submit_blacklist(pub):
|
|||
|
||||
|
||||
def test_form_file_field_with_wrong_value(pub):
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'test'
|
||||
|
|
|
@ -789,8 +789,6 @@ def test_formdata_generated_document_odt_to_pdf_download_push_to_portfolio(
|
|||
assert resp.content_type == 'application/pdf'
|
||||
assert b'PDF' in resp.body
|
||||
|
||||
if pub.loggederror_class:
|
||||
pub.loggederror_class.wipe()
|
||||
resp = login(get_app(pub), username='foo', password='foo').get(form_location)
|
||||
with mock.patch('wcs.portfolio.http_post_request') as http_post_request:
|
||||
http_post_request.return_value = None, 400, 'null', None # fail
|
||||
|
@ -1571,8 +1569,6 @@ def test_formdata_named_wscall_in_comment(pub):
|
|||
resp = get_app(pub).get('/test/')
|
||||
assert 'Hello XbarY.' in resp.text
|
||||
|
||||
if pub.loggederror_class:
|
||||
pub.loggederror_class.wipe()
|
||||
with mock.patch('wcs.qommon.misc._http_request') as mocked_http_request:
|
||||
mocked_http_request.side_effect = ConnectionError('...')
|
||||
resp = get_app(pub).get('/test/')
|
||||
|
|
|
@ -421,9 +421,6 @@ def test_get_data_source_custom_view(pub):
|
|||
|
||||
|
||||
def test_data_source_custom_view_digest(pub):
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
CardDef.wipe()
|
||||
carddef = CardDef()
|
||||
carddef.name = 'foo'
|
||||
|
|
|
@ -137,9 +137,6 @@ def test_python_datasource(pub):
|
|||
|
||||
|
||||
def test_python_datasource_errors(pub, error_email, http_requests, emails, caplog):
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
# invalid python expression
|
||||
datasource = {'type': 'formula', 'value': 'foobar', 'notify_on_errors': True, 'record_on_errors': True}
|
||||
assert data_sources.get_items(datasource) == []
|
||||
|
@ -392,9 +389,6 @@ def test_json_datasource(pub, requests_pub, http_requests):
|
|||
|
||||
|
||||
def test_json_datasource_bad_url(pub, error_email, http_requests, emails, caplog):
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
datasource = {'type': 'json', 'value': 'http://remote.example.net/404'}
|
||||
assert data_sources.get_items(datasource) == []
|
||||
assert emails.count() == 0
|
||||
|
@ -467,9 +461,6 @@ def test_json_datasource_bad_url(pub, error_email, http_requests, emails, caplog
|
|||
|
||||
|
||||
def test_json_datasource_bad_url_scheme(pub, error_email, emails):
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
datasource = {'type': 'json', 'value': '', 'notify_on_errors': True, 'record_on_errors': True}
|
||||
assert data_sources.get_items(datasource) == []
|
||||
assert emails.count() == 0
|
||||
|
@ -820,9 +811,6 @@ def test_geojson_datasource(pub, requests_pub, http_requests):
|
|||
|
||||
|
||||
def test_geojson_datasource_bad_url(pub, http_requests, error_email, emails):
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
datasource = {
|
||||
'type': 'geojson',
|
||||
'value': 'http://remote.example.net/404',
|
||||
|
@ -890,9 +878,6 @@ def test_geojson_datasource_bad_url(pub, http_requests, error_email, emails):
|
|||
|
||||
|
||||
def test_geojson_datasource_bad_url_scheme(pub, error_email, emails):
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
datasource = {'type': 'geojson', 'value': ''}
|
||||
assert data_sources.get_items(datasource) == []
|
||||
assert emails.count() == 0
|
||||
|
|
|
@ -2567,8 +2567,6 @@ def test_form_digest_date(pub):
|
|||
def test_form_digest_error(pub):
|
||||
FormDef.wipe()
|
||||
pub.custom_view_class.wipe()
|
||||
if pub.is_using_postgresql():
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
formdef = FormDef()
|
||||
formdef.name = 'foobar'
|
||||
|
|
|
@ -13,8 +13,6 @@ def teardown_module(module):
|
|||
|
||||
|
||||
def test_deprecated_error(pub):
|
||||
pub.loggederror_class.wipe()
|
||||
|
||||
pub.record_deprecated_usage('foo bar')
|
||||
assert pub.loggederror_class.count() == 1
|
||||
error = pub.loggederror_class.select()[0]
|
||||
|
|
|
@ -226,7 +226,6 @@ def test_workflow_send_mail_template_with_sql(superuser, emails):
|
|||
# check nothing is sent and an error is logged if the mail template is
|
||||
# missing
|
||||
emails.empty()
|
||||
pub.loggederror_class.wipe()
|
||||
MailTemplate.wipe()
|
||||
item.perform(formdata)
|
||||
pub.get_request().response.process_after_jobs()
|
||||
|
|
|
@ -185,7 +185,6 @@ def test_webservice_on_error_with_sql(http_requests, emails, notify_on_errors, r
|
|||
pub.write_cfg()
|
||||
|
||||
NamedWsCall.wipe()
|
||||
pub.loggederror_class.wipe()
|
||||
FormDef.wipe()
|
||||
|
||||
wscall = NamedWsCall()
|
||||
|
|
|
@ -139,6 +139,7 @@ def create_temporary_pub(sql_mode=False, templates_mode=False, lazy_mode=False):
|
|||
if not created:
|
||||
if sql_mode:
|
||||
pub.cfg['postgresql'] = {'database': known_elements.sql_db_name, 'user': os.environ['USER']}
|
||||
pub.loggederror_class.wipe()
|
||||
pub.write_cfg()
|
||||
return pub
|
||||
|
||||
|
|
|
@ -356,7 +356,6 @@ def test_jump_bad_python_condition(two_pubs):
|
|||
formdata = formdef.data_class()()
|
||||
item = JumpWorkflowStatusItem()
|
||||
|
||||
two_pubs.loggederror_class.wipe()
|
||||
item.condition = {'type': 'python', 'value': 'form_var_foobar == 0'}
|
||||
assert item.must_jump(formdata) is False
|
||||
assert two_pubs.loggederror_class.count() == 1
|
||||
|
@ -392,8 +391,6 @@ def test_jump_django_conditions(two_pubs):
|
|||
two_pubs.substitutions.feed(formdata)
|
||||
item = JumpWorkflowStatusItem()
|
||||
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
item.condition = {'type': 'django', 'value': '1 < 2'}
|
||||
assert item.must_jump(formdata) is True
|
||||
|
||||
|
@ -557,8 +554,6 @@ def test_dispatch_auto(two_pubs):
|
|||
pytest.skip('this requires sql')
|
||||
return
|
||||
|
||||
two_pubs.loggederror_class.wipe()
|
||||
|
||||
formdef = FormDef()
|
||||
formdef.name = 'baz'
|
||||
formdef.fields = [
|
||||
|
@ -642,8 +637,6 @@ def test_dispatch_computed(two_pubs):
|
|||
pytest.skip('this requires sql')
|
||||
return
|
||||
|
||||
two_pubs.loggederror_class.wipe()
|
||||
|
||||
formdef = FormDef()
|
||||
formdef.name = 'baz'
|
||||
formdef.store()
|
||||
|
@ -1186,8 +1179,6 @@ def test_register_comment_django_escaping(pub, emails):
|
|||
|
||||
|
||||
def test_register_comment_attachment(two_pubs):
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
two_pubs.substitutions.feed(MockSubstitutionVariables())
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -3257,8 +3248,6 @@ def test_geolocate_action_enable_geolocation(two_pubs):
|
|||
|
||||
|
||||
def test_geolocate_address(two_pubs):
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.geolocations = {'base': 'bla'}
|
||||
formdef.name = 'baz'
|
||||
|
@ -3435,8 +3424,6 @@ def test_geolocate_image(pub):
|
|||
|
||||
|
||||
def test_geolocate_map(two_pubs):
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'baz'
|
||||
formdef.geolocations = {'base': 'bla'}
|
||||
|
@ -4366,8 +4353,6 @@ def test_profile(two_pubs):
|
|||
def test_set_backoffice_field(http_requests, two_pubs):
|
||||
Workflow.wipe()
|
||||
FormDef.wipe()
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
wf = Workflow(name='xxx')
|
||||
wf.backoffice_fields_formdef = WorkflowBackofficeFieldsFormDef(wf)
|
||||
wf.backoffice_fields_formdef.fields = [
|
||||
|
@ -4501,8 +4486,6 @@ def test_set_backoffice_field(http_requests, two_pubs):
|
|||
def test_set_backoffice_field_decimal(http_requests, two_pubs):
|
||||
Workflow.wipe()
|
||||
FormDef.wipe()
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
wf = Workflow(name='xxx')
|
||||
wf.backoffice_fields_formdef = WorkflowBackofficeFieldsFormDef(wf)
|
||||
wf.backoffice_fields_formdef.fields = [
|
||||
|
@ -5247,8 +5230,6 @@ def test_set_backoffice_field_items(two_pubs):
|
|||
def test_set_backoffice_field_date(two_pubs):
|
||||
Workflow.wipe()
|
||||
FormDef.wipe()
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
wf = Workflow(name='xxx')
|
||||
wf.backoffice_fields_formdef = WorkflowBackofficeFieldsFormDef(wf)
|
||||
st1 = wf.add_status('Status1')
|
||||
|
@ -6208,7 +6189,6 @@ def test_call_external_workflow_manual_targeting(two_pubs):
|
|||
|
||||
FormDef.wipe()
|
||||
CardDef.wipe()
|
||||
two_pubs.loggederror_class.wipe()
|
||||
|
||||
# carddef workflow, with global action to increment a counter in its
|
||||
# backoffice fields.
|
||||
|
@ -6396,7 +6376,6 @@ def test_call_external_workflow_manual_queryset_targeting(two_pubs):
|
|||
|
||||
FormDef.wipe()
|
||||
CardDef.wipe()
|
||||
two_pubs.loggederror_class.wipe()
|
||||
|
||||
# carddef workflow, with global action to increment a counter in its
|
||||
# backoffice fields.
|
||||
|
|
|
@ -64,8 +64,6 @@ def two_pubs(request):
|
|||
def test_create_carddata(two_pubs):
|
||||
CardDef.wipe()
|
||||
FormDef.wipe()
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
|
||||
carddef = CardDef()
|
||||
carddef.name = 'My card'
|
||||
|
@ -340,8 +338,6 @@ def test_create_carddata_with_links(pub):
|
|||
def test_create_carddata_with_map_field(two_pubs):
|
||||
CardDef.wipe()
|
||||
FormDef.wipe()
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
|
||||
carddef = CardDef()
|
||||
carddef.name = 'My card'
|
||||
|
@ -740,7 +736,6 @@ def test_edit_carddata_manual_targeting(two_pubs):
|
|||
|
||||
FormDef.wipe()
|
||||
CardDef.wipe()
|
||||
two_pubs.loggederror_class.wipe()
|
||||
|
||||
# carddef
|
||||
carddef = CardDef()
|
||||
|
@ -1175,7 +1170,6 @@ def test_assign_carddata_manual_targeting(two_pubs):
|
|||
|
||||
FormDef.wipe()
|
||||
CardDef.wipe()
|
||||
two_pubs.loggederror_class.wipe()
|
||||
two_pubs.user_class.wipe()
|
||||
|
||||
user = two_pubs.user_class()
|
||||
|
|
|
@ -55,8 +55,6 @@ def two_pubs(request):
|
|||
|
||||
def test_create_formdata(two_pubs):
|
||||
FormDef.wipe()
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
two_pubs.tracking_code_class.wipe()
|
||||
|
||||
target_formdef = FormDef()
|
||||
|
@ -163,8 +161,6 @@ def test_create_formdata_migration(pub):
|
|||
|
||||
def test_create_formdata_tracking_code(two_pubs, emails):
|
||||
FormDef.wipe()
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
two_pubs.tracking_code_class.wipe()
|
||||
|
||||
target_wf = Workflow(name='send-mail')
|
||||
|
@ -222,8 +218,6 @@ def test_create_formdata_tracking_code(two_pubs, emails):
|
|||
|
||||
def test_create_formdata_attach_to_history(two_pubs):
|
||||
FormDef.wipe()
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
two_pubs.tracking_code_class.wipe()
|
||||
|
||||
target_formdef = FormDef()
|
||||
|
|
Loading…
Reference in New Issue