def test_get_help_page_no_access(workbook, anon_es_testapp, es_testapp, anon_html_es_testapp, html_es_testapp, static_help_page_default, static_help_page_in_review, static_help_page_deleted): notice_pytest_fixtures(workbook) wait_for_index(es_testapp) success = True for app_name, testapp, role in [("anon_es", anon_es_testapp, 'anon'), ("es", es_testapp, 'system'), ("anon_html_es", anon_html_es_testapp, 'anon'), ("html_es", html_es_testapp, 'system')]: for help_page, is_public in [(static_help_page_default, False), (static_help_page_in_review, False), (static_help_page_deleted, False)]: expected_code = 200 if is_public else ( 403 if role == 'anon' else 200) page_name = help_page['name'] help_page_url = "/" + page_name res = testapp.get(help_page_url, status=(200, 301, 403, 404)).maybe_follow() actual_code = res.status_code if actual_code == expected_code: print("%s => %s: SUCCESS (%s)" % (app_name, page_name, actual_code)) else: print("%s => %s: FAILED (%s, not %s): %s..." % (app_name, page_name, actual_code, expected_code, res.body[:20])) success = False assert success, "Test failed."
def app_settings(request, wsgi_server_host_port, conn, DBSession): # noQA - We didn't choose the fixture name. notice_pytest_fixtures(request, wsgi_server_host_port, conn, DBSession) settings = make_app_settings_dictionary() settings['auth0.audiences'] = 'http://%s:%s' % wsgi_server_host_port settings[DBSESSION] = DBSession return settings
def test_accession_anontestapp(request, test_accession_app, external_tx, zsa_savepoints): """ TestApp with JSON accept header. """ notice_pytest_fixtures(request, test_accession_app, external_tx, zsa_savepoints) environ = { 'HTTP_ACCEPT': 'application/json', } return webtest.TestApp(test_accession_app, environ)
def test_accession_app(request, check_constraints, zsa_savepoints, app_settings): notice_pytest_fixtures(request, check_constraints, zsa_savepoints, app_settings) app_settings = app_settings.copy() app_settings[ 'accession_factory'] = 'encoded.server_defaults.test_accession' return main({}, **app_settings)
def test_test_accession_server_defaults(admin, test_accession_anontestapp): notice_pytest_fixtures(admin, test_accession_anontestapp) email = admin['email'] extra_environ = {'REMOTE_USER': str(email)} res = test_accession_anontestapp.post_json( '/testing_server_default', {}, status=201, extra_environ=extra_environ, ) item = res.json['@graph'][0] assert item['accession'].startswith('TSTAB') test_accession_anontestapp.patch_json( res.location, {}, status=200, extra_environ=extra_environ, )
def threadlocals(request, dummy_request, registry): notice_pytest_fixtures(request, dummy_request, registry) threadlocal_manager.push({'request': dummy_request, 'registry': registry}) yield dummy_request threadlocal_manager.pop()