def register_hr_redirections(): """ Run this only once """ from invenio.goto_engine import register_redirection plugin = 'goto_plugin_cern_hr_documents' ## Staff rules and regulations for modif in range(1, 20): for lang in ('en', 'fr'): register_redirection('hr-srr-modif%02d-%s' % (modif, lang), plugin, parameters={'type': 'SSR', 'lang': lang, 'modif': modif}) for lang in ('en', 'fr'): register_redirection('hr-srr-%s' % lang, plugin, parameters={'type': 'SSR', 'lang': lang, 'modif': 0}) ## Operational Circulars for number in range(1, 10): for lang in ('en', 'fr'): register_redirection('hr-oper-circ-%s-%s' % (number, lang), plugin, parameters={'type': 'OPER-CIRC', 'document': lang, 'number': number}) for number, special_document in ((2, 'implementation'), (2, 'annex'), (3, 'archiving'), (3, 'annex')): for lang in ('en', 'fr'): register_redirection('hr-circ-%s-%s-%s' % (number, special_document, lang), plugin, parameters={'type': 'OPER-CIRC', 'document': '%s-%s' % (special_document, lang), 'number': number}) ## Administrative Circulars: for number in range(1, 32): for lang in ('en', 'fr'): register_redirection('hr-admin-circ-%s-%s' % (number, lang), plugin, parameters={'type': 'ADMIN-CIRC', 'document': lang, 'number': number})
def register_hr_redirections(): """ Run this only once """ from invenio.goto_engine import register_redirection plugin = 'goto_plugin_cern_hr_documents' ## Staff rules and regulations for modif in range(1, 20): for lang in ('en', 'fr'): register_redirection('hr-srr-modif%02d-%s' % (modif, lang), plugin, parameters={'type': 'SRR', 'lang': lang, 'modif': modif}) for lang in ('en', 'fr'): register_redirection('hr-srr-%s' % lang, plugin, parameters={'type': 'SRR', 'lang': lang, 'modif': 0}) ## Operational Circulars for number in range(1, 10): for lang in ('en', 'fr'): register_redirection('hr-oper-circ-%s-%s' % (number, lang), plugin, parameters={'type': 'OPER-CIRC', 'document': lang, 'number': number}) for number, special_document in ((2, 'implementation'), (2, 'annex'), (3, 'archiving'), (3, 'annex')): for lang in ('en', 'fr'): register_redirection('hr-circ-%s-%s-%s' % (number, special_document, lang), plugin, parameters={'type': 'OPER-CIRC', 'document': '%s-%s' % (special_document, lang), 'number': number}) ## Administrative Circulars: for number in range(1, 32): for lang in ('en', 'fr'): register_redirection('hr-admin-circ-%s-%s' % (number, lang), plugin, parameters={'type': 'ADMIN-CIRC', 'document': lang, 'number': number})
def test_simple_absolute_redirection(self): """webstyle - test simple absolute redirection via goto_plugin_simple""" register_redirection('first_record', 'goto_plugin_simple', parameters={'url': CFG_SITE_URL + '/record/1'}) self.assertEqual(get_final_url(CFG_SITE_URL + '/goto/first_record'), CFG_SITE_URL + '/record/1')
def test_invalid_external_redirection(self): """webstyle - test simple absolute redirection to https via goto_plugin_simple""" register_redirection('invalid_external', 'goto_plugin_simple', parameters={'url': 'http://www.google.com'}) self.assertRaises(HTTPError, get_final_url, CFG_SITE_URL + '/goto/google')
def test_latest_article_redirection(self): """webstyle - test redirecting to latest article via goto_plugin_latest_record""" register_redirection('latest_article', 'goto_plugin_latest_record', parameters={'cc': 'Articles'}) self.assertEqual(get_final_url(CFG_SITE_URL + '/goto/latest_article'), CFG_SITE_URL + '/record/108')
def FIXME_TICKET_1293_test_URL_argument_in_redirection(self): """webstyle - test redirecting while passing arguments on the URL""" register_redirection("latest_article", "goto_plugin_latest_record", parameters={"cc": "Articles"}) self.assertEqual( get_final_url(CFG_SITE_URL + "/goto/latest_article?format=.pdf"), CFG_SITE_URL + "/record/97/files/0002060.pdf", )
def test_simple_relative_redirection(self): """webstyle - test simple relative redirection via goto_plugin_simple""" from invenio.goto_engine import register_redirection register_redirection('first_record', 'goto_plugin_simple', parameters={'url': '/record/1'}) self.assertEqual(get_final_url(CFG_SITE_URL + '/goto/first_record'), CFG_SITE_URL + '/record/1')
def FIXME_TICKET_1293_test_URL_argument_in_redirection(self): """webstyle - test redirecting while passing arguments on the URL""" register_redirection('latest_article', 'goto_plugin_latest_record', parameters={'cc': 'Articles'}) self.assertEqual( get_final_url(CFG_SITE_URL + '/goto/latest_article?format=.pdf'), CFG_SITE_URL + '/record/97/files/0002060.pdf')
def FIXME_TICKET_1293_test_latest_pdf_article_redirection(self): """webstyle - test redirecting to latest article via goto_plugin_latest_record""" register_redirection( "latest_pdf_article", "goto_plugin_latest_record", parameters={"cc": "Articles", "format": ".pdf"} ) self.assertEqual( get_final_url(CFG_SITE_URL + "/goto/latest_pdf_article"), CFG_SITE_URL + "/record/97/files/0002060.pdf" )
def test_updating_redirection(self): """webstyle - test updating redirection""" register_redirection('first_record', 'goto_plugin_simple', parameters={'url': '/record/1'}) update_redirection('first_record', 'goto_plugin_simple', parameters={'url': '/record/2'}) self.assertEqual(get_final_url(CFG_SITE_URL + '/goto/first_record'), CFG_SITE_URL + '/record/2')
def FIXME_TICKET_1293_test_latest_pdf_article_redirection(self): """webstyle - test redirecting to latest article via goto_plugin_latest_record""" register_redirection('latest_pdf_article', 'goto_plugin_latest_record', parameters={ 'cc': 'Articles', 'format': '.pdf' }) self.assertEqual( get_final_url(CFG_SITE_URL + '/goto/latest_pdf_article'), CFG_SITE_URL + '/record/97/files/0002060.pdf')
def FIXME_TICKET_1293_test_latest_pdf_article_redirection(self): """webstyle - test redirecting to latest article via goto_plugin_latest_record""" register_redirection('latest_pdf_article', 'goto_plugin_latest_record', parameters={'cc': 'Articles', 'format': '.pdf'}) self.assertEqual(get_final_url(CFG_SITE_URL + '/goto/latest_pdf_article'), CFG_SITE_URL + '/record/97/files/0002060.pdf')
def FIXME_TICKET_1293_test_URL_argument_in_redirection(self): """webstyle - test redirecting while passing arguments on the URL""" register_redirection('latest_article', 'goto_plugin_latest_record', parameters={'cc': 'Articles'}) self.assertEqual(get_final_url(CFG_SITE_URL + '/goto/latest_article?format=.pdf'), CFG_SITE_URL + '/record/97/files/0002060.pdf')
def test_simple_relative_redirection(self): """webstyle - test simple relative redirection via goto_plugin_simple""" register_redirection('first_record', 'goto_plugin_simple', parameters={'url': '/record/1'}) self.assertEqual(get_final_url(CFG_SITE_URL + '/goto/first_record'), CFG_SITE_URL + '/record/1')
def test_simple_absolute_redirection_https(self): """webstyle - test simple absolute redirection to https via goto_plugin_simple""" register_redirection( "first_record", "goto_plugin_simple", parameters={"url": CFG_SITE_SECURE_URL + "/record/1"} ) self.assertEqual(get_final_url(CFG_SITE_URL + "/goto/first_record"), CFG_SITE_SECURE_URL + "/record/1")
def test_simple_absolute_redirection_https(self): """webstyle - test simple absolute redirection to https via goto_plugin_simple""" register_redirection('first_record', 'goto_plugin_simple', parameters={'url': CFG_SITE_SECURE_URL + '/record/1'}) self.assertEqual(get_final_url(CFG_SITE_URL + '/goto/first_record'), CFG_SITE_SECURE_URL + '/record/1')
def test_invalid_external_redirection(self): """webstyle - test simple absolute redirection to https via goto_plugin_simple""" register_redirection("invalid_external", "goto_plugin_simple", parameters={"url": "http://www.google.com"}) self.assertRaises(HTTPError, get_final_url, CFG_SITE_URL + "/goto/google")
def test_simple_relative_redirection(self): """webstyle - test simple relative redirection via goto_plugin_simple""" register_redirection("first_record", "goto_plugin_simple", parameters={"url": "/record/1"}) self.assertEqual(get_final_url(CFG_SITE_URL + "/goto/first_record"), CFG_SITE_URL + "/record/1")
def test_updating_redirection(self): """webstyle - test updating redirection""" register_redirection("first_record", "goto_plugin_simple", parameters={"url": "/record/1"}) update_redirection("first_record", "goto_plugin_simple", parameters={"url": "/record/2"}) self.assertEqual(get_final_url(CFG_SITE_URL + "/goto/first_record"), CFG_SITE_URL + "/record/2")
def test_latest_article_redirection(self): """webstyle - test redirecting to latest article via goto_plugin_latest_record""" register_redirection('latest_article', 'goto_plugin_latest_record', parameters={'cc': 'Articles'}) self.assertEqual(get_final_url(CFG_SITE_URL + '/goto/latest_article'), CFG_SITE_URL + '/record/128')
def test_latest_article_redirection(self): """webstyle - test redirecting to latest article via goto_plugin_latest_record""" register_redirection("latest_article", "goto_plugin_latest_record", parameters={"cc": "Articles"}) self.assertEqual(get_final_url(CFG_SITE_URL + "/goto/latest_article"), CFG_SITE_URL + "/record/128")