From: Aarni Koskela Date: Thu, 31 Dec 2015 00:46:08 +0000 (+0200) Subject: Add test for frontend update_command X-Git-Tag: 2.3.1~31^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F311%2Fhead;p=thirdparty%2Fbabel.git Add test for frontend update_command --- diff --git a/.gitignore b/.gitignore index 67ba223a..d8f8bc16 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,6 @@ test-env babel/global.dat babel/global.dat.json tests/messages/data/project/i18n/long_messages.pot -tests/messages/data/project/i18n/temp.pot +tests/messages/data/project/i18n/temp* tests/messages/data/project/i18n/en_US /venv* diff --git a/tests/messages/test_frontend.py b/tests/messages/test_frontend.py index 4676adc1..f958b805 100644 --- a/tests/messages/test_frontend.py +++ b/tests/messages/test_frontend.py @@ -24,9 +24,9 @@ import unittest from babel import __version__ as VERSION from babel.dates import format_datetime -from babel.messages import frontend +from babel.messages import frontend, Catalog from babel.util import LOCALTZ -from babel.messages.pofile import read_po +from babel.messages.pofile import read_po, write_po from babel._compat import StringIO @@ -1059,6 +1059,39 @@ compiling catalog %r to %r if os.path.isfile(mo_file): os.unlink(mo_file) + def test_update(self): + template = Catalog() + template.add("1") + template.add("2") + template.add("3") + tmpl_file = os.path.join(self._i18n_dir(), 'temp-template.pot') + with open(tmpl_file, "wb") as outfp: + write_po(outfp, template) + po_file = os.path.join(self._i18n_dir(), 'temp1.po') + self.cli.run(sys.argv + ['init', + '-l', 'fi', + '-o', po_file, + '-i', tmpl_file + ]) + with open(po_file, "r") as infp: + catalog = read_po(infp) + assert len(catalog) == 3 + + # Add another entry to the template + + template.add("4") + + with open(tmpl_file, "wb") as outfp: + write_po(outfp, template) + + self.cli.run(sys.argv + ['update', + '-l', 'fi_FI', + '-o', po_file, + '-i', tmpl_file]) + + with open(po_file, "r") as infp: + catalog = read_po(infp) + assert len(catalog) == 4 # Catalog was updated def test_parse_mapping(): buf = StringIO(