0ad60e5 text unit test should validate using installed mo file

3 files Authored by jdennis 11 years ago, Committed by rcritten 11 years ago,
    text unit test should validate using installed mo file
    
    We use custom gettext classes (e.g. GettextFactory &
    NGettextFactory). We should exercise those classes with an installed
    binary mo file to demonstrate we are actually returning the expected
    translated strings for all strings defined as being translatable.
    
    The test logic in install/po/test_i18n.py was recently enhanced to
    make this type of testing easier and more complete.
    tests/test_ipalib/test_text.py should import the new i18n test support
    and run it.
    
    Previously tests/test_ipalib/test_text.py made a feeble but incomplete
    attempt to do the above but even that was often not run because the
    test would skip because the necessary test files were not available
    unless they had been manually created in the install/po subdir. It is
    now possible to correct those deficiencies in the test.
    
    This patch does the following:
    
    * Moves the location of i18n test code and adjust references to it.
      install/po/test_i18n.py was moved to tests/i18n.py. This permits
      tests/test_ipalib/test_text.py to import the i18n test utilities
      in a clean fashion. The Makefile in install/po now calls this
      same file.
    
    * Modfies test function in test_i18n.py to accept function pointers
      for retreiving a translation.
    
    * Imports test_i18n.py from the install/po directory in the tree
    
    * Creates a tmp directory for the test localedir
    
    * Parses the current ipa.pot file in install/po and generates
      a test po and mo file with special unicode markers. It installs
      the test mo file in the tmp localedir. This is accomplished by
      calling create_po() from the test_i18n.py file.
    
    * If any of the above does not work it raises nose.SkipTest with
      the reason, and skips the test.
    
    * It sets up functions to get a translation and a plural translation
      via our text.GettextFactory class and text.NGettextFactory class
      respectively. This are the functions we use intenally to get
      translations. It set the localdir and lang which are used by those
      classes to match our test configuration. It then runs a validation
      test on every translation and it's plural found in the test.po file
      by calling po_file_iterate and passed it the function pointers to
      our internal routines.
    
    * At the conclusion of the test it cleans up after itself.
    
    Note: extraneous files are not created in the tree, only a tmp
    directory is utilized.
    
    Validating msgid's in C code was insufficient.
    
    * Make the discovery of format conversions much more robust by authoring
      a new function parse_printf_fmt() that is able to discover each
      format conversion in a string and break it into it's individual
      subparts. One of those subparts is the argument selector index. In c
      code we need to know if the argumenet selector index is present to
      know if translator can reorder the substitution strings.
    
      This replaces the simplistic python_anonymous_substitutions_regexp
      which was insufficient to deal with other programming languages
      (e.g. c).
    
    * Add get_prog_langs() function to return the set of programming
      languages a msgid appears in. This is necessar because the msdid
      validation is programming language specific.
    
    https://fedorahosted.org/freeipa/ticket/2582
    
        
file modified
+5 -28
tests/i18n.py install/po/test_i18n.py
file renamed
+147 -32
file modified
+76 -87