diff --git a/docs/api.rst b/docs/api.rst index 0e2c22a27..192cc0912 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1,34 +1,29 @@ .. This file is part of Invenio Copyright (C) 2014, 2015 CERN. Invenio is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Invenio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Invenio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. .. _api: API === -.. toctree:: - :maxdepth: 1 - - base - Legacy ------ .. toctree:: :maxdepth: 1 legacy/bibrecord diff --git a/invenio/testsuite/test_i18n.py b/invenio/testsuite/test_i18n.py deleted file mode 100644 index 16915e95d..000000000 --- a/invenio/testsuite/test_i18n.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of Invenio. -# Copyright (C) 2008, 2010, 2011, 2013, 2015 CERN. -# -# Invenio is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# Invenio is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Invenio; if not, write to the Free Software Foundation, Inc., -# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -"""Unit tests for messages library.""" - -__revision__ = "$Id$" - -from invenio_base import i18n as messages -from invenio_base.globals import cfg -from invenio.testsuite import make_test_suite, run_test_suite, InvenioTestCase - - -class MessagesLanguageTest(InvenioTestCase): - """ - Testing language-related functions - """ - - def test_lang_list_long_ordering(self): - """messages - preserving language order""" - lang_list_long = messages.language_list_long() - - # Preliminary test: same number of languages in both lists - self.assertEqual(len(lang_list_long), - len(cfg['CFG_SITE_LANGS'])) - - - for lang, cfg_lang in zip(lang_list_long, - cfg['CFG_SITE_LANGS']): - self.assertEqual(lang[0], - cfg_lang) - - def test_wash_invalid_language(self): - """messages - washing invalid language code""" - self.assertEqual(messages.wash_language('python'), - cfg['CFG_SITE_LANG']) - - def test_wash_dashed_language(self): - """messages - washing dashed language code (fr-ca)""" - if 'fr' not in cfg['CFG_SITE_LANGS']: - self.assertEqual(messages.wash_language('fr-ca'), - cfg['CFG_SITE_LANG']) - else: - self.assertEqual(messages.wash_language('fr-ca'), - 'fr') - - def test_wash_languages(self): - """messages - washing multiple languages""" - if 'de' not in cfg['CFG_SITE_LANGS']: - self.assertEqual(messages.wash_languages(['00', - '11', - '22', - 'de']), - cfg['CFG_SITE_LANG']) - else: - self.assertEqual(messages.wash_languages(['00', - '11', - '22', - 'de']), - 'de') - self.assertEqual(messages.wash_languages(['00', - '11', - '22']), - cfg['CFG_SITE_LANG']) - - def test_rtl_direction(self): - """messages - right-to-left language detection""" - # Arabic is right-to-left: - self.assertEqual(messages.is_language_rtl('ar'), True) - # English is not right-to-left: - self.assertEqual(messages.is_language_rtl('en'), False) - - -TEST_SUITE = make_test_suite(MessagesLanguageTest,) - -if __name__ == "__main__": - run_test_suite(TEST_SUITE) diff --git a/invenio/testsuite/test_manage.py b/invenio/testsuite/test_manage.py deleted file mode 100644 index 2ac92ac12..000000000 --- a/invenio/testsuite/test_manage.py +++ /dev/null @@ -1,145 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of Invenio. -# Copyright (C) 2013, 2015 CERN. -# -# Invenio is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# Invenio is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Invenio; if not, write to the Free Software Foundation, Inc., -# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -"""Unit tests for the inveniomanage script.""" - -from __future__ import print_function - -import sys - -from invenio_base.utils import run_py_func -from invenio.testsuite import make_test_suite, run_test_suite, InvenioTestCase - - -class Catcher(object): - """Helper decorator to test raw_input.""" - ## see: http://stackoverflow.com/questions/13480632/python-stringio-selectively-place-data-into-stdin - - def __init__(self, handler): - self.handler = handler - self.inputs = [] - - def __enter__(self): - self.__stdin = sys.stdin - self.__stdout = sys.stdout - sys.stdin = self - sys.stdout = self - - def __exit__(self, type, value, traceback): - sys.stdin = self.__stdin - sys.stdout = self.__stdout - - def write(self, value): - self.__stdout.write(value) - result = self.handler(value) - if result is not None: - self.inputs.append(result) - - def readline(self): - return self.inputs.pop() - - def getvalue(self): - return self.__stdout.getvalue() - - def truncate(self, pos): - return self.__stdout.truncate(pos) - - -class InveniomanageTest(InvenioTestCase): - - def test_upgrade_show_applied_cmd(self): - """ Test `upgrade show applied` command. """ - from invenio_upgrader.manage import main - out = run_py_func(main, 'upgrader show applied').out - - expected = '>>> Following upgrade(s) have been applied:' - self.assertTrue(expected in out.split('\n'), - "%s was not found in output %s" % (expected, out)) - - def test_upgrade_show_pending_cmd(self): - """ Test `upgrade show pending` command. """ - from invenio_upgrader.manage import main - out = run_py_func(main, 'upgrader show pending').out - - lines = out.split('\n') - expected = ('>>> Following upgrade(s) are ready to be applied:', - '>>> All upgrades have been applied.') - self.assertTrue(expected[0] in lines or expected[1] in lines, - "%s was not found in output %s" % (expected, lines)) - - - def test_signals_usage(self): - """ Test signal handling. """ - from invenio_base.scripts.database import main as db_main - from invenio_base.signals import pre_command, post_command - from invenio_base.manage import main, version as im_version - - def pre_handler_version(sender, *args, **kwargs): - print('>>> pre_handler_version') - - def post_handler_version(sender, *args, **kwargs): - print('>>> post_handler_version') - - # Bind only `inveniomanage version` command to pre/post handler. - pre_command.connect(pre_handler_version, sender=im_version) - post_command.connect(post_handler_version, sender=im_version) - - def pre_handler_general_test(sender, *args, **kwargs): - print('>>> pre_handler_general') - - def post_handler_general_test(sender, *args, **kwargs): - print('>>> post_handler_general') - - # Bind all commands to pre/post general handler. - pre_command.connect(pre_handler_general_test) - pre_command.connect(post_handler_general_test) - - # Expect both version and general handlers. - out = run_py_func(main, 'inveniomanage version').out - - lines = out.split('\n') - expected = ('>>> pre_handler_version', - '>>> post_handler_version', - '>>> pre_handler_general', - '>>> post_handler_general') - for line in expected: - self.assertTrue(line in lines, - "%s was not found in output %s" % (line, lines)) - - # Expect only general handlers. - out = run_py_func(db_main, 'database uri').out - - lines = out.split('\n') - expected = ('>>> pre_handler_general', - '>>> post_handler_general') - for line in expected: - self.assertTrue(line in lines, - "%s was not found in output %s" % (line, lines)) - - notexpected = ('>>> pre_handler_version', - '>>> post_handler_version') - for line in notexpected: - self.assertFalse(line in lines, - "%s was not expected in output %s" % (line, lines)) - - -TEST_SUITE = make_test_suite(InveniomanageTest) - -if __name__ == "__main__": - run_test_suite(TEST_SUITE) diff --git a/invenio/testsuite/test_views.py b/invenio/testsuite/test_views.py deleted file mode 100644 index 5ec4085f8..000000000 --- a/invenio/testsuite/test_views.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of Invenio. -# Copyright (C) 2015 CERN. -# -# Invenio is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# Invenio is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Invenio; if not, write to the Free Software Foundation, Inc., -# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -"""Unit tests for the inveniomanage script.""" - -from invenio.testsuite import InvenioTestCase, make_test_suite, run_test_suite - - -class ViewsTest(InvenioTestCase): - - """Test base views.""" - - def test_ping_view(self): - """Test /ping endpoint.""" - response = self.client.get("/ping") - - assert 'OK' == response.data - - -TEST_SUITE = make_test_suite(ViewsTest) - -if __name__ == "__main__": - run_test_suite(TEST_SUITE)