## 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.
"""WebMessage Regression Test Suite."""

__revision__ = "$Id$"

from invenio.config import CFG_SITE_URL, CFG_SITE_LANG
from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, \
                              test_web_page_content, merge_error_messages, \
                              InvenioTestCase
webmessage = lazy_import('invenio.webmessage')

CFG_WEBMESSAGE_STATUS_CODE = lazy_import(
    'invenio.webmessage_query:CFG_WEBMESSAGE_STATUS_CODE')
check_quota = lazy_import('invenio.webmessage_query:check_quota')
count_nb_messages = lazy_import('invenio.webmessage_query:count_nb_messages')
create_message = lazy_import('invenio.webmessage_query:create_message')
datetext_default = lazy_import('invenio.webmessage_query:datetext_default')
delete_all_messages = lazy_import(
    'invenio.webmessage_query:delete_all_messages')
delete_message_from_user_inbox = lazy_import(
    'invenio.webmessage_query:delete_message_from_user_inbox')
get_all_messages_for_user = lazy_import(
    'invenio.webmessage_query:get_all_messages_for_user')
get_gids_from_groupnames = lazy_import(
    'invenio.webmessage_query:get_gids_from_groupnames')
## 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 WebMessage."""

__revision__ = \
    "$Id$"

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase
webmessage_mailutils = lazy_import('invenio.webmessage_mailutils')


class TestQuotingMessage(InvenioTestCase):
    """Test for quoting messages."""
    def test_simple_quoting_per_block(self):
        """webmessage - test quoting simple message (HTML, per block)"""
        text = """Dear romeo
I received your mail
>>Would you like to come with me to the restaurant?
Of course!
>>>>When could we get together?
Reply to my question please.
    see you..."""
        expected_text = """Dear romeo<br/>
I received your mail<br/>
Пример #3
0
##
## 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.

__revision__ = "$Id$"

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

calculate_start_date = lazy_import('invenio.webcomment:calculate_start_date')


class TestCalculateStartDate(InvenioTestCase):
    """Test for calculating previous date."""

    def test_previous_year(self):
        """webcomment - calculate_start_date, values bigger than one year"""
        self.assert_(int(calculate_start_date('1y')[:4]) > 2007)
        self.assert_(int(calculate_start_date('13m')[:4]) > 2007)
        self.assert_(int(calculate_start_date('55w')[:4]) > 2007)
        self.assert_(int(calculate_start_date('370d')[:4]) > 2007)

    def test_with_random_values(self):
        """webcomment - calculate_start_date, various random values"""
        self.assert_(calculate_start_date('1d') > '2009-07-08 14:39:39')
Пример #4
0
## along with Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
"""BibAuthority Regression Test Suite."""

__revision__ = "$Id$"

from invenio.bibauthority_config import \
    CFG_BIBAUTHORITY_RECORD_CONTROL_NUMBER_FIELD, \
    CFG_BIBAUTHORITY_TYPE_NAMES, \
    CFG_BIBAUTHORITY_PREFIX_SEP

from invenio.testutils import make_test_suite, run_test_suite, \
    InvenioTestCase
from invenio.importutils import lazy_import

is_authority_record = lazy_import(
    'invenio.bibauthority_engine:is_authority_record')
get_dependent_records_for_control_no = lazy_import(
    'invenio.bibauthority_engine:get_dependent_records_for_control_no')
get_dependent_records_for_recID = lazy_import(
    'invenio.bibauthority_engine:get_dependent_records_for_recID')
guess_authority_types = lazy_import(
    'invenio.bibauthority_engine:guess_authority_types')
get_low_level_recIDs_from_control_no = lazy_import(
    'invenio.bibauthority_engine:get_low_level_recIDs_from_control_no')
get_control_nos_from_recID = lazy_import(
    'invenio.bibauthority_engine:get_control_nos_from_recID')
get_index_strings_by_control_no = lazy_import(
    'invenio.bibauthority_engine:get_index_strings_by_control_no')
guess_main_name_from_authority_recID = lazy_import(
    'invenio.bibauthority_engine:guess_main_name_from_authority_recID')
get_fieldvalues = lazy_import('invenio.search_engine_utils:get_fieldvalues')
## 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.

"""Testing functions for the page getter module.
"""

__revision__ = "$Id$"


from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase
HTTPAsyncPageGetter = lazy_import('invenio.websearch_external_collections_getter:HTTPAsyncPageGetter')
async_download = lazy_import('invenio.websearch_external_collections_getter:async_download')


class AsyncDownloadTest(InvenioTestCase):
    """Test suite for websearch_external_collections_*"""

    def test_async_download(self):
        """websearch_external_collections_getter - asynchronous download"""

        ## Test various cases for the async_download function:
        ##   - test 1 working page: invenio-software.org
        ##   - test 1 unresolvable name: rjfreijoiregjreoijgoirg.fr
        ##   - test 1 bad IP: 1.2.3.4
        ## Return the list of errors.
        checks = [
Пример #6
0
## 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.
"""bibindex_engine_tokenizer_tests - unit tests for tokenizers

There should always be at least one test class for each class in b_e_t.
"""

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

load_tokenizers = lazy_import('invenio.bibindex_engine_utils:load_tokenizers')

_TOKENIZERS = None


class TestAuthorTokenizerScanning(InvenioTestCase):
    """Test BibIndex name tokenization"""
    def setUp(self):
        _TOKENIZERS = load_tokenizers()
        self.tokenizer = _TOKENIZERS["BibIndexAuthorTokenizer"]()
        self.scan = self.tokenizer.scan_string_for_phrases

    def test_bifnt_scan_single(self):
        """BibIndexAuthorTokenizer - scanning single names like 'Dido'"""
        teststr = "Dido"
        output = self.scan(teststr)
Пример #7
0
## 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.

"""
Contains Test Cases for Revision Verifier module used along with BibUpload.
"""

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, nottest

get_record = lazy_import('invenio.search_engine:get_record')
print_record = lazy_import('invenio.search_engine:print_record')
bibupload = lazy_import('invenio.bibupload:bibupload')
xml_marc_to_records = lazy_import('invenio.bibupload:xml_marc_to_records')

record_get_field_value = lazy_import('invenio.bibrecord:record_get_field_value')
record_xml_output = lazy_import('invenio.bibrecord:record_xml_output')

from invenio.bibupload_revisionverifier \
                        import RevisionVerifier, \
                               InvenioBibUploadConflictingRevisionsError, \
                               InvenioBibUploadMissing005Error, \
                               InvenioBibUploadUnchangedRecordError, \
                               InvenioBibUploadInvalidRevisionError

from invenio.bibupload_regression_tests import GenericBibUploadTest, \
##
## 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.

# pylint: disable=E1102

"""Unit tests for bibmatch."""

__revision__ = "$Id$"

from invenio.config import CFG_SITE_RECORD
from invenio.importutils import lazy_import
from invenio.testutils import InvenioTestCase, make_test_suite, run_test_suite

create_records = lazy_import('invenio.bibrecord:create_records')
match_records = lazy_import('invenio.bibmatch_engine:match_records')


class BibMatchTest(InvenioTestCase):
    """Test functions to check the functionality of bibmatch."""

    def setUp(self):
        """setting up helper variables for tests"""
        self.textmarc = """
000000020 001__ 20
000000020 041__ $$aeng
000000020 088__ $$aJYFL-RR-82-7
000000020 100__ $$aArje, J$$uUniversity of Jyvaskyla
000000020 245__ $$aCharge creation and reset mechanisms in an ion guide isotope separator (IGIS)
000000020 260__ $$aJyvaskyla$$bFinland Univ. Dept. Phys.$$cJul 1982
Пример #9
0
## 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.
"""WebLinkback - Unit Test Suite"""

import datetime

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

split_in_days = lazy_import('invenio.weblinkback:split_in_days')

from invenio.weblinkback_config import CFG_WEBLINKBACK_TYPE, CFG_WEBLINKBACK_STATUS


class TestSplitLinkbacksInInsertionDayGroups(InvenioTestCase):
    """Test for splitting linkbacks in insertion day groups"""
    def setUp(self):
        # [(linkback_id, origin_url, recid, additional_properties, linkback_type, linkback_status, insert_time)]
        self.test_data = ((23L, 'URL', 42, None,
                           CFG_WEBLINKBACK_TYPE['TRACKBACK'],
                           CFG_WEBLINKBACK_STATUS['APPROVED'],
                           datetime.datetime(2011, 10, 21, 0, 1, 40)),
                          (22L, 'URL', 41, None,
                           CFG_WEBLINKBACK_TYPE['TRACKBACK'],
                           CFG_WEBLINKBACK_STATUS['APPROVED'],
## 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 WebAlert engine."""

__revision__ = \
    "$Id$"

from invenio.config import CFG_SITE_URL
from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

RecordHTMLParser = lazy_import('invenio.htmlparser:RecordHTMLParser')


class TestWashHTMLtoText(InvenioTestCase):
    """Test HTML to text conversion."""
    def test_wash_html_to_text(self):
        """webalert - stripping HTML markup for alert emails"""
        htparser = RecordHTMLParser()
        htparser.feed('''<style type="text/css">
                    <!--
                       div.thumbMosaic {display:inline;}
                       div.thumbMosaic span{display:none;}
                       div.thumbMosaic:hover span{display:inline;position:absolute;}
                     -->
                     </style><!--START_NOT_FOR_TEXT--><strong>Abracadabra!</strong><!--END_NOT_FOR_TEXT--><br/><a class="moreinfo" href="%(CFG_SITE_URL)s">Detailed Record</a>'''
                      % {'CFG_SITE_URL': CFG_SITE_URL})
Пример #11
0
try:
    import chardet
    CHARDET_AVAILABLE = True
except ImportError:
    CHARDET_AVAILABLE = False

try:
    from unidecode import unidecode
    UNIDECODE_AVAILABLE = True
except ImportError:
    UNIDECODE_AVAILABLE = False

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

decode_to_unicode = lazy_import('invenio.textutils:decode_to_unicode')
guess_minimum_encoding = lazy_import(
    'invenio.textutils:guess_minimum_encoding')
strip_accents = lazy_import('invenio.textutils:strip_accents')
translate_latex2unicode = lazy_import(
    'invenio.textutils:translate_latex2unicode')
translate_to_ascii = lazy_import('invenio.textutils:translate_to_ascii')
transliterate_ala_lc = lazy_import('invenio.textutils:transliterate_ala_lc')
wash_for_utf8 = lazy_import('invenio.textutils:wash_for_utf8')
wash_for_xml = lazy_import('invenio.textutils:wash_for_xml')
wrap_text_in_a_box = lazy_import('invenio.textutils:wrap_text_in_a_box')


class GuessMinimumEncodingTest(InvenioTestCase):
    """Test functions related to guess_minimum_encoding function."""
    def test_guess_minimum_encoding(self):
Пример #12
0
## 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.

# pylint: disable=E1102
"""Unit tests for bibmatch."""

__revision__ = "$Id$"

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

compare_fieldvalues_normal = lazy_import(
    'invenio.bibmatch_validator:compare_fieldvalues_normal')
compare_fieldvalues_authorname = lazy_import(
    'invenio.bibmatch_validator:compare_fieldvalues_authorname')
compare_fieldvalues_identifier = lazy_import(
    'invenio.bibmatch_validator:compare_fieldvalues_identifier')
compare_fieldvalues_title = lazy_import(
    'invenio.bibmatch_validator:compare_fieldvalues_title')
compare_fieldvalues_date = lazy_import(
    'invenio.bibmatch_validator:compare_fieldvalues_date')
get_paired_comparisons = lazy_import(
    'invenio.bibmatch_validator:get_paired_comparisons')


class BibMatchTest(InvenioTestCase):
    """Test functions to check the validator of Bibmatch."""
    def test_validation_get_paired_comparisons(self):
Пример #13
0
## 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.
"""Testing module for BibSort Engine"""

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

binary_search = lazy_import('invenio.bibsort_engine:binary_search')
perform_delete_record = lazy_import(
    'invenio.bibsort_engine:perform_delete_record')
perform_insert_record = lazy_import(
    'invenio.bibsort_engine:perform_insert_record')
perform_modify_record = lazy_import(
    'invenio.bibsort_engine:perform_modify_record')


class TestBibSort(InvenioTestCase):
    """Test BibSort."""
    def test_perform_modify_record(self):
        """bibsort - testing perform_modify_record"""
        data_dict = {1: 'a', 2: 'c', 3: 'e', 4: 'g', 5: 'i', 6: 'k', 7: 's'}
        data_dict_ordered = {1: 8, 2: 16, 3: 24, 4: 32, 5: 40, 6: 48, 7: 56}
        data_list_sorted = [1, 2, 3, 4, 5, 6, 7]
##
## 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 bibcatalog_system_rt library."""

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase
bibcatalog_system_rt = lazy_import('invenio.bibcatalog_system_rt')


class BibCatalogSystemRTTest(InvenioTestCase):
    """Testing of BibCatalog."""

    def setUp(self):
        bibcatalog_system_rt.CFG_BIBCATALOG_SYSTEM_RT_DEFAULT_USER = '******'
        bibcatalog_system_rt.CFG_BIBCATALOG_SYSTEM_RT_DEFAULT_PWD = 'testpass'
        bibcatalog_system_rt.CFG_BIBCATALOG_SYSTEM_RT_URL = 'http://testingdomainbadbad.invenio-software.org'
        self.rt = bibcatalog_system_rt.BibCatalogSystemRT()

    def tearDown(self):
        pass

    def test_rt_run_command_fails_with_bum_environment(self):
Пример #15
0
__revision__ = "$Id$"

import os
from logging import StreamHandler, DEBUG
from cStringIO import StringIO

from invenio.errorlib import register_exception
from invenio.config import CFG_SITE_URL, CFG_PREFIX, CFG_TMPDIR, CFG_PATH_PDFTK
from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, \
                              test_web_page_content, merge_error_messages, \
                              InvenioTestCase
from invenio.webinterface_handler_flask import with_app_context

websubmit_file_stamper = lazy_import('invenio.websubmit_file_stamper')


class WebSubmitWebPagesAvailabilityTest(InvenioTestCase):
    """Check WebSubmit web pages whether they are up or not."""
    def test_submission_pages_availability(self):
        """websubmit - availability of submission pages"""

        baseurl = CFG_SITE_URL + '/submit/'

        _exports = ['', 'direct']

        error_messages = []
        for url in [baseurl + page for page in _exports]:
            error_messages.extend(test_web_page_content(url))
        if error_messages:
## 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 search engine."""

__revision__ = \
    "$Id$"

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

search_engine = lazy_import('invenio.search_engine')
CFG_CERN_SITE = lazy_import('invenio.config:CFG_CERN_SITE')


class TestMiscUtilityFunctions(InvenioTestCase):
    """Test whatever non-data-specific utility functions are essential."""
    def test_ziplist2x2(self):
        """search engine - ziplist 2 x 2"""
        self.assertEqual(search_engine.ziplist([1, 2], [3, 4]),
                         [[1, 3], [2, 4]])

    def test_ziplist3x3(self):
        """search engine - ziplist 3 x 3"""
        self.assertEqual(
            search_engine.ziplist([1, 2, 3], ['a', 'b', 'c'], [9, 8, 7]),
            [[1, 'a', 9], [2, 'b', 8], [3, 'c', 7]])
## 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 plotextract script."""

__revision__ = "$Id$"


from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

assemble_caption = lazy_import('invenio.plotextractor:assemble_caption')
find_open_and_close_braces = lazy_import('invenio.plotextractor:find_open_and_close_braces')
intelligently_find_filenames = lazy_import('invenio.plotextractor:intelligently_find_filenames')
put_it_together = lazy_import('invenio.plotextractor:put_it_together')
get_converted_image_name = lazy_import('invenio.plotextractor_output_utils:get_converted_image_name')
remove_dups = lazy_import('invenio.plotextractor_output_utils:remove_dups')
run_shell_command = lazy_import('invenio.shellutils:run_shell_command')


class PutItTogetherTest(InvenioTestCase):
    """Test functions related to the put_it_together function."""

    def setUp(self):
        self.empty_images_and_captions = []
        self.dummy_line_index = -1
        self.empty_lines = []
Пример #18
0
## 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 search engine."""

__revision__ = \
    "$Id: search_engine_tests.py,v 1.20 2008/08/11 12:49:27 kaplun Exp $"

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

QueryResult = lazy_import(
    'invenio.bibexport_method_fieldexporter_dblayer:QueryResult')


def _create_record_marc_xml():
    """Creates MARC XML containing one record"""
    xml_text = """
    <record>
      <datafield tag="260" ind1=" " ind2=" ">
        <subfield code="c">14 Dec 1998</subfield>
      </datafield>
      <datafield tag="260" ind1="A" ind2="B">
        <subfield code="c">14 Dec 1999</subfield>
      </datafield>
      <datafield tag="300" ind1=" " ind2=" ">
        <subfield code="a">6 p</subfield>
      </datafield>
Пример #19
0
## along with Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
"""Test cases for the BibFormat engine. Also test
some utilities function in bibformat_utils module"""

__revision__ = "$Id$"

# pylint: disable=C0301

import os
import sys

from invenio.config import CFG_TMPDIR
from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase
bibformat = lazy_import('invenio.bibformat')
bibformat_engine = lazy_import('invenio.bibformat_engine')
bibformat_utils = lazy_import('invenio.bibformat_utils')
bibformat_config = lazy_import('invenio.bibformat_config')
bibformat_engine = lazy_import('invenio.bibformat_engine')
bibformatadminlib = lazy_import('invenio.bibformatadminlib')

#CFG_BIBFORMAT_OUTPUTS_PATH = "..%setc%soutput_formats" % (os.sep, os.sep)
#CFG_BIBFORMAT_TEMPLATES_PATH = "..%setc%sformat_templates" % (os.sep, os.sep)
#CFG_BIBFORMAT_ELEMENTS_PATH = "elements"
CFG_BIBFORMAT_OUTPUTS_PATH = "%s" % (CFG_TMPDIR)
CFG_BIBFORMAT_TEMPLATES_PATH = "%s" % (CFG_TMPDIR)
CFG_BIBFORMAT_ELEMENTS_PATH = "%s%stests_bibformat_elements" % (CFG_TMPDIR,
                                                                os.sep)
CFG_BIBFORMAT_ELEMENTS_IMPORT_PATH = "tests_bibformat_elements"
Пример #20
0
##
## 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 BibEdit functions"""

import re

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase
get_xml_from_textmarc = lazy_import(
    'invenio.bibedit_utils:get_xml_from_textmarc')
perform_doi_search = lazy_import('invenio.bibedit_engine:perform_doi_search')


class TextmarcToXMLTests(InvenioTestCase):
    """ Test utility functions to convert textmarc to XML """
    def test_get_xml_from_textmarc_success(self):
        textmarc = """100__ $$aDoe, J.$$uCERN
        245__ $$aPion production by 24 GeV/c protons in hydrogen
        260__ $$c1961
        300__ $$a15"""
        output = get_xml_from_textmarc(1, textmarc)
        self.assertEqual(output['resultMsg'], 'textmarc_parsing_success')

        xml_expected_output = """<record>
    <controlfield tag="001">1</controlfield>
Пример #21
0
## 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 oai repository."""

__revision__ = "$Id$"


import re
from cStringIO import StringIO

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

oai_repository_server = lazy_import('invenio.oai_repository_server')


class TestVerbs(InvenioTestCase):
    """Test for OAI verb functionality."""

    def test_verbs(self):
        """oairepository - testing verbs"""
        self.assertNotEqual(None, re.search("Identify", oai_repository_server.oai_identify({'verb': 'Identify'})))
        ret = StringIO()
        oai_repository_server.oai_list_records_or_identifiers(ret, {'verb': 'ListIdentifiers', 'metadataPrefix': 'marcxml'})
        self.assertNotEqual(None, re.search("ListIdentifiers", ret.getvalue()))
        ret = StringIO()
        oai_repository_server.oai_list_records_or_identifiers(ret, {'verb': 'ListRecords', 'metadataPrefix': 'marcxml'})
        self.assertNotEqual(None, re.search("ListRecords", ret.getvalue()))
        self.assertNotEqual(None, re.search("ListMetadataFormats", oai_repository_server.oai_list_metadata_formats({'verb': 'ListMetadataFormats'})))
## 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 indexing engine."""

__revision__ = \
    "$Id$"

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase
bibindex_engine = lazy_import('invenio.bibindex_engine')


class TestListSetOperations(InvenioTestCase):
    """Tests for list set operations."""
    def test_list_union(self):
        """bibindex engine - list union"""
        self.assertEqual([1, 2, 3, 4],
                         bibindex_engine.list_union([1, 2, 3], [1, 3, 4]))


class TestWashIndexTerm(InvenioTestCase):
    """Tests for washing index terms, useful for both searching and indexing."""
    def test_wash_index_term_short(self):
        """bibindex engine - wash index term, short word"""
        self.assertEqual("ellis", bibindex_engine.wash_index_term("ellis"))
## 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.
"""BibFormat module regression tests."""

__revision__ = "$Id$"

from invenio.config import CFG_SITE_URL, CFG_SITE_LANG, CFG_SITE_RECORD
from invenio.importutils import lazy_import
from invenio.testutils import InvenioTestCase, make_test_suite, \
    run_test_suite, test_web_page_content

format_record = lazy_import('invenio.bibformat:format_record')
BibFormatObject = lazy_import('invenio.bibformat_engine:BibFormatObject')


class BibFormatAPITest(InvenioTestCase):
    """Check BibFormat API"""
    def test_basic_formatting(self):
        """bibformat - Checking BibFormat API"""
        result = format_record(recID=73,
                               of='hx',
                               ln=CFG_SITE_LANG,
                               verbose=0,
                               search_pattern=[],
                               xml_record=None,
                               user_info=None,
                               on_the_fly=True)
Пример #24
0
##
## 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 solrutils library."""

from invenio import intbitset
from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

replace_invalid_solr_characters = lazy_import(
    'invenio.solrutils_bibindex_indexer:replace_invalid_solr_characters')
get_collection_filter = lazy_import(
    'invenio.solrutils_bibrank_searcher:get_collection_filter')


class TestReplaceInvalidCharacters(InvenioTestCase):
    """Test for removal of invalid Solr characters and control characters."""
    def test_no_replacement(self):
        """solrutils - no characters to replace"""
        utext_in = unicode('foo\nbar\tfab\n\r', 'utf-8')
        utext_out = unicode('foo\nbar\tfab\n\r', 'utf-8')
        self.assertEqual(utext_out, replace_invalid_solr_characters(utext_in))

    def test_replace_control_characters(self):
        """solrutils - replacement of control characters"""
        self.assertEqual(u'abc \nde',
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

# pylint: disable=E1102
"""WebSession Regression Test Suite."""

__revision__ = \
    "$Id$"

from mechanize import Browser

from invenio.dbquery import run_sql
from invenio.config import CFG_SITE_SECURE_URL
from invenio.importutils import lazy_import
from invenio.testutils import InvenioTestCase, make_test_suite, run_test_suite

webuser = lazy_import('invenio.webuser')


class IsUserSuperAdminTests(InvenioTestCase):
    """Test functions related to the isUserSuperAdmin function."""
    def setUp(self):
        self.id_admin = run_sql(
            'SELECT id FROM user WHERE nickname="admin"')[0][0]
        self.id_hyde = run_sql(
            'SELECT id FROM user WHERE nickname="hyde"')[0][0]

    def test_isUserSuperAdmin_admin(self):
        """webuser - isUserSuperAdmin with admin"""
        self.failUnless(
            webuser.isUserSuperAdmin(webuser.collect_user_info(self.id_admin)))
## 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 ranking engine."""

__revision__ = "$Id$"

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

bibrank_tag_based_indexer = lazy_import('invenio.bibrank_tag_based_indexer')
split_ranges = lazy_import('invenio.bibrank:split_ranges')


class TestListSetOperations(InvenioTestCase):
    """Test list set operations."""

    def test_union_dicts(self):
        """bibrank tag based indexer - union dicts"""
        self.assertEqual({1: 5, 2: 6, 3: 9, 4: 10, 10: 1}, bibrank_tag_based_indexer.union_dicts({1: 5, 2: 6, 3: 9}, {3:9, 4:10, 10: 1}))

    def test_split_ranges(self):
        """bibrank tag based indexer - split ranges"""
        self.assertEqual([[0, 500], [600, 1000]], split_ranges("0-500,600-1000"))

TEST_SUITE = make_test_suite(TestListSetOperations,)
import re

from cStringIO import StringIO

from invenio.config import CFG_SITE_URL, \
     CFG_OAI_SLEEP, \
     CFG_OAI_LOAD, \
     CFG_OAI_ID_FIELD
from invenio.dbquery import run_sql
from invenio.importutils import lazy_import
from invenio.intbitset import intbitset
from invenio.testutils import make_test_suite, run_test_suite, \
                              test_web_page_content, merge_error_messages, \
                              InvenioTestCase

oai_repository_server = lazy_import('invenio.oai_repository_server')
search_engine = lazy_import('invenio.search_engine')


class OAIRepositoryTouchSetTest(InvenioTestCase):
    """Check OAI-PMH consistency when touching a set."""
    def setUp(self):
        """Backup the current configuration"""
        self.timestamps = run_sql("SELECT id, last_updated FROM oaiREPOSITORY")

    def tearDown(self):
        """Restore timestamps"""
        for id, last_updated in self.timestamps:
            run_sql("UPDATE oaiREPOSITORY SET last_updated=%s WHERE id=%s",
                    (last_updated, id))
Пример #28
0
## 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 WebJournal."""

__revision__ = \
    "$Id$"

# pylint invenio/modules/webjournal/lib/webjournal_tests.py

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase

issue_is_later_than = lazy_import('invenio.webjournal:issue_is_later_than')
compare_issues = lazy_import('invenio.webjournal_utils:compare_issues')


class TestCompareIssues(InvenioTestCase):
    """Tests for comparing issues."""
    def test_compare_issues(self):
        """webjournal - tests comparing issues"""

        issue1 = '06/2009'
        issue2 = '07/2009'
        self.assertEqual(compare_issues(issue1, issue2), -1)

        issue1 = '07/2009'
        issue2 = '06/2009'
        self.assertEqual(compare_issues(issue1, issue2), 1)
Пример #29
0
from datetime import datetime
from invenio.importutils import lazy_import
from invenio.testutils import InvenioTestCase, make_test_suite, run_test_suite

from invenio.access_control_config import CFG_WEBACCESS_WARNING_MSGS
from invenio.config import \
        CFG_SITE_URL, \
        CFG_PREFIX, \
        CFG_BIBDOCFILE_FILEDIR, \
        CFG_SITE_RECORD, \
        CFG_WEBDIR, \
        CFG_TMPDIR, \
        CFG_PATH_MD5SUM
from invenio.mimetypeutils import CFG_HAS_MAGIC

MoreInfo = lazy_import('invenio.bibdocfile:MoreInfo')
Md5Folder = lazy_import('invenio.bibdocfile:Md5Folder')
guess_format_from_url = lazy_import('invenio.bibdocfile:guess_format_from_url')


class BibDocFsInfoTest(InvenioTestCase):
    """Regression tests about the table bibdocfsinfo"""
    def setUp(self):
        from invenio.bibdocfile import BibRecDocs
        self.my_bibrecdoc = BibRecDocs(2)
        self.unique_name = self.my_bibrecdoc.propose_unique_docname('file')
        self.my_bibdoc = self.my_bibrecdoc.add_new_file(CFG_PREFIX + '/lib/webtest/invenio/test.jpg', docname=self.unique_name)
        self.my_bibdoc_id = self.my_bibdoc.id

    def tearDown(self):
        self.my_bibdoc.expunge()
Пример #30
0
## 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.
"""BibAuthority Regression Test Suite."""

__revision__ = "$Id$"

from invenio.legacy.bibauthority.config import \
    CFG_BIBAUTHORITY_RECORD_CONTROL_NUMBER_FIELD, \
    CFG_BIBAUTHORITY_TYPE_NAMES, \
    CFG_BIBAUTHORITY_PREFIX_SEP

from invenio.testsuite import make_test_suite, run_test_suite, \
    InvenioTestCase
from invenio.importutils import lazy_import
is_authority_record = lazy_import('invenio.legacy.bibauthority.engine:is_authority_record')
get_dependent_records_for_control_no = lazy_import('invenio.legacy.bibauthority.engine:get_dependent_records_for_control_no')
get_dependent_records_for_recID = lazy_import('invenio.legacy.bibauthority.engine:get_dependent_records_for_recID')
guess_authority_types = lazy_import('invenio.legacy.bibauthority.engine:guess_authority_types')
get_low_level_recIDs_from_control_no = lazy_import('invenio.legacy.bibauthority.engine:get_low_level_recIDs_from_control_no')
get_control_nos_from_recID = lazy_import('invenio.legacy.bibauthority.engine:get_control_nos_from_recID')
get_index_strings_by_control_no = lazy_import('invenio.legacy.bibauthority.engine:get_index_strings_by_control_no')
guess_main_name_from_authority_recID = lazy_import('invenio.legacy.bibauthority.engine:guess_main_name_from_authority_recID')
get_fieldvalues = lazy_import('invenio.legacy.bibrecord:get_fieldvalues')

class BibAuthorityEngineTest(InvenioTestCase):
    """Check BibEdit web pages whether they are up or not."""

    def test_bibauthority_is_authority_record(self):
        """bibauthority - test is_authority_record()"""
        self.assertFalse(is_authority_record(1))
Пример #31
0
##
## 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.
"""
The Refextract unit test suite

The tests will not modifiy the database.
"""

import re

from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase
# Import the minimal necessary methods and variables needed to run Refextract
refextract_re = lazy_import('invenio.refextract_re')
setup_loggers = lazy_import('invenio.docextract_utils:setup_loggers')
search_from_reference = lazy_import(
    'invenio.refextract_api:search_from_reference')


class ReTest(InvenioTestCase):
    def setUp(self):
        setup_loggers(verbosity=1)

    def test_word(self):
        r = refextract_re._create_regex_pattern_add_optional_spaces_to_word_characters(
            'ABC')
        self.assertEqual(r, ur'A\s*B\s*C\s*')

    def test_reference_section_title_pattern(self):