[damned-lies] Moved domain-related tests to its own test case
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Moved domain-related tests to its own test case
- Date: Sat, 23 Jun 2018 20:42:53 +0000 (UTC)
commit 3347caa274a5ae8999fd6a97efa4d7db3424d05c
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Jun 23 21:00:35 2018 +0200
Moved domain-related tests to its own test case
stats/tests/git/testmodule/help_mallard/de/de.po | 62 ++++++++
stats/tests/tests.py | 187 ++++++++++++-----------
2 files changed, 163 insertions(+), 86 deletions(-)
---
diff --git a/stats/tests/git/testmodule/help_mallard/de/de.po
b/stats/tests/git/testmodule/help_mallard/de/de.po
new file mode 100644
index 00000000..cb133c04
--- /dev/null
+++ b/stats/tests/git/testmodule/help_mallard/de/de.po
@@ -0,0 +1,62 @@
+# German translation of gnome-hello docs.
+# Mario Blättermann <mario blaettermann gmail com>, 2008, 2009, 2012.
+# Daniel Winzen <d winzen4 de>, 2012
+# Christian Kirbach <Christian Kirbach gmail com>, 2012.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: gnome-hello\n"
+"POT-Creation-Date: 2012-08-11 11:12+0000\n"
+"PO-Revision-Date: 2012-09-09 16:53+0100\n"
+"Last-Translator: Mario Blättermann <mario blaettermann gmail com>\n"
+"Language-Team: Deutsch <gnome-de gnome org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-Language: German\n"
+"X-Poedit-Country: GERMANY\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. Put one translator per line, in the form NAME <EMAIL>, YEAR1, YEAR2
+msgctxt "_"
+msgid "translator-credits"
+msgstr ""
+"Mario Blättermann <mario blaettermann gmail com>, 2008, 2009, 2012\n"
+"Daniel Winzen <d winzen4 de>, 2012\n"
+"Christian Kirbach <Christian Kirbach gmail com>, 2012."
+
+#. This is a reference to an external file such as an image or video. When
+#. the file changes, the md5 hash will change to let you know you need to
+#. update your localized copy. The msgstr is not used at all. Set it to
+#. whatever you like once you have updated your copy of the file.
+#.
+#. This is a reference to an external file such as an image or video. When
+#. the file changes, the md5 hash will change to let you know you need to
+#. update your localized copy. The msgstr is not used at all. Set it to
+#. whatever you like once you have updated your copy of the file.
+#.
+#. This is a reference to an external file such as an image or video. When
+#. the file changes, the md5 hash will change to let you know you need to
+#. update your localized copy. The msgstr is not used at all. Set it to
+#. whatever you like once you have updated your copy of the file.
+#.
+#. This is a reference to an external file such as an image or video. When
+#. the file changes, the md5 hash will change to let you know you need to
+#. update your localized copy. The msgstr is not used at all. Set it to
+#. whatever you like once you have updated your copy of the file.
+#: C/index.page:7(media) C/index.page:26(media)
+msgctxt "_"
+msgid ""
+"external ref='figures/gnome-hello-logo.png' "
+"md5='1ae47b7a7c4fbeb1f6bb72c0cf18d389'"
+msgstr "original"
+
+#: C/index.page:6(info/desc)
+msgid "Help for GNOME Hello."
+msgstr "Hilfe zu GNOME-Hallo."
+
+#: C/index.page:8(info/title)
+msgctxt "text"
+msgid "GNOME Hello"
+msgstr "GNOME-Hallo"
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 4afc7e1b..0a0d6bd8 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -124,40 +124,6 @@ class ModuleTestCase(TestCase):
help_domain.save()
self.assertEqual(list(self.branch.get_domains().keys()), ['po'])
- @test_scratchdir
- def test_domain_linguas(self):
- help_domain = self.branch.get_domains()['help']
- help_domain.linguas_location = "help/Makefile.am"
- self.assertEqual(help_domain.get_linguas(self.branch), {
- 'langs': None,
- 'error': 'Entry for this language is not present in ALL_LINGUAS variable in '
- 'help/Makefile.am file.',
- })
- help_domain.linguas_location = "help/Makefile.am#HELP_LINGUAS"
- self.assertEqual(help_domain.get_linguas(self.branch), {
- 'langs': ['de', 'fr'],
- 'error': 'Entry for this language is not present in HELP_LINGUAS variable in '
- 'help/Makefile.am file.',
- })
- help_domain.linguas_location = ''
- self.assertEqual(help_domain.get_linguas(self.branch), {
- 'langs': ['de', 'fr'],
- 'error': 'DOC_LINGUAS list doesn’t include this language.',
- })
-
- def test_domain_xgettext_command(self):
- domain = self.branch.get_domains()['po']
- self.assertEqual(
- domain.get_xgettext_command(self.branch),
- (['xgettext', '--files-from', 'POTFILES.in', '--directory',
- os.path.join(settings.SCRATCHDIR, 'git', 'gnome-hello'),
- '--from-code', 'utf-8',
- '--add-comments', '--output', 'gnome-hello.pot', '--msgid-bugs-address',
- 'https://bugzilla.gnome.org/enter_bug.cgi?product=test&keywords=I18N+L10N&component=test'],
- {'GETTEXTDATADIRS': os.path.dirname(utils.ITS_DATA_DIR)}
- )
- )
-
@test_scratchdir
def test_branch_stats(self):
lang = Language.objects.create(name='xxx', locale='xxx')
@@ -291,18 +257,6 @@ class ModuleTestCase(TestCase):
self.assertEqual(mail.outbox[0].extra_headers, {settings.EMAIL_HEADER_NAME: 'stringchange'})
self.assertIn('"%s"' % new_string, mail.outbox[0].body)
- @test_scratchdir
- def test_http_pot(self):
- dom = Domain.objects.create(
- module=self.mod, name='http-po',
- description='UI Translations', dtype='ui',
- pot_method='url',
- pot_params='https://l10n.gnome.org/POT/damned-lies.master/damned-lies.master.pot'
- )
- self.branch.checkout()
- potfile, errs = dom.generate_pot_file(self.branch)
- self.assertTrue(potfile.exists())
-
@test_scratchdir
def test_dynamic_po(self):
""" Test the creation of a blank po file for a new language """
@@ -445,6 +399,107 @@ class ModuleTestCase(TestCase):
self.assertEqual(self.mod.homepage, "http://git.gnome.org/browse/gnome-hello")
+@override_settings(SCRATCHDIR=str(Path(__file__).parent))
+class DomainTests(TestCase):
+ @classmethod
+ def setUpTestData(cls):
+ Branch.checkout_on_creation = False
+ Branch.checkout = mocked_checkout
+ cls.mod = Module.objects.create(
+ name="testmodule", vcs_type='git',
+ bugs_base='https://gitlab.gnome.org/GNOME/testmodule/issues',
+ )
+ cls.branch = Branch(module=cls.mod, name="master")
+ cls.branch.save(update_statistics=False)
+
+ def test_domain_linguas(self):
+ help_domain = Domain.objects.create(
+ module=self.mod, name='help', dtype='doc', directory='help_mallard'
+ )
+ help_domain.linguas_location = "help_mallard/Makefile.am"
+ self.assertEqual(help_domain.get_linguas(self.branch), {
+ 'langs': None,
+ 'error': 'Entry for this language is not present in ALL_LINGUAS variable in '
+ 'help_mallard/Makefile.am file.',
+ })
+ help_domain.linguas_location = "help_mallard/Makefile.am#HELP_LINGUAS"
+ self.assertEqual(help_domain.get_linguas(self.branch), {
+ 'langs': ['es', 'fr'],
+ 'error': 'Entry for this language is not present in HELP_LINGUAS variable in '
+ 'help_mallard/Makefile.am file.',
+ })
+ help_domain.linguas_location = ''
+ self.assertEqual(help_domain.get_linguas(self.branch), {
+ 'langs': ['es', 'fr'],
+ 'error': 'DOC_LINGUAS list doesn’t include this language.',
+ })
+
+ def test_domain_xgettext_command(self):
+ domain = Domain.objects.create(
+ module=self.mod, name='po', dtype='ui', directory='po'
+ )
+ self.assertEqual(
+ domain.get_xgettext_command(self.branch),
+ (['xgettext', '--files-from', 'POTFILES.in', '--directory',
+ os.path.join(settings.SCRATCHDIR, 'git', 'testmodule'),
+ '--from-code', 'utf-8',
+ '--add-comments', '--output', 'testmodule.pot', '--msgid-bugs-address',
+ 'https://gitlab.gnome.org/GNOME/testmodule/issues'],
+ {'GETTEXTDATADIRS': os.path.dirname(utils.ITS_DATA_DIR)}
+ )
+ )
+
+ def test_doc_domain_docbook(self):
+ """
+ Test Docbook-style help
+ """
+ domain = Domain.objects.create(
+ module=self.mod, name='release-notes', dtype='doc', directory='help_docbook'
+ )
+ potfile, errs = utils.generate_doc_pot_file(self.branch, domain)
+ self.assertEqual(errs, [])
+ doc_format = domain.doc_format(self.branch)
+ self.assertEqual(doc_format.tool, 'xml2po')
+ self.assertEqual(doc_format.format, 'docbook')
+ pot_path = self.branch.domain_path(domain) / "C" / "release-notes.pot"
+ self.assertTrue(pot_path.exists())
+ self.addCleanup(os.remove, str(pot_path))
+ self.assertIn('#: C/rnlookingforward.xml:11(para)', pot_path.read_text())
+ res = utils.get_fig_stats(pot_path, doc_format=doc_format)
+ self.assertEqual(len(res), 1)
+ self.assertEqual(res[0]['path'], "figures/rnusers.nautilus.png")
+
+ def test_doc_domain_mallard(self):
+ """
+ Test Mallard-style help (with itstool)
+ """
+ domain = Domain.objects.create(
+ module=self.mod, name='release-notes', dtype='doc', directory='help_mallard'
+ )
+ potfile, errs = utils.generate_doc_pot_file(self.branch, domain)
+ self.assertEqual(errs, [])
+ doc_format = domain.doc_format(self.branch)
+ self.assertEqual(potfile.name, 'release-notes.pot')
+ self.assertEqual(doc_format.tool, 'itstool')
+ self.assertEqual(doc_format.format, 'mallard')
+ self.addCleanup(os.remove, str(potfile))
+ self.assertIn('#: C/what-is.page:7', potfile.read_text())
+ res = utils.get_fig_stats(potfile, doc_format=doc_format)
+ self.assertEqual(len(res), 1)
+ self.assertEqual(res[0]['path'], "figures/gnome-hello-logo.png")
+ self.assertEqual(res[0]['hash'], "1ae47b7a7c4fbeb1f6bb72c0cf18d389")
+
+ def test_http_pot(self):
+ dom = Domain.objects.create(
+ module=self.mod, name='http-po', dtype='ui',
+ pot_method='url',
+ pot_params='https://l10n.gnome.org/POT/damned-lies.master/damned-lies.master.pot'
+ )
+ potfile, errs = dom.generate_pot_file(self.branch)
+ self.addCleanup(os.remove, str(potfile))
+ self.assertTrue(potfile.exists())
+
+
class StatisticsTests(TestCase):
fixtures = ['sample_data.json']
@@ -648,46 +703,6 @@ class UtilsTests(TestCase):
['index.page', 'what-is.page', 'legal.xml']
)
- def test_generate_doc_potfile_docbook(self):
- """
- Test Docbook-style help
- """
- domain = Domain.objects.create(
- module=self.mod, name='release-notes', dtype='doc', directory='help_docbook'
- )
- potfile, errs = utils.generate_doc_pot_file(self.branch, domain)
- self.assertEqual(errs, [])
- doc_format = domain.doc_format(self.branch)
- self.assertEqual(doc_format.tool, 'xml2po')
- self.assertEqual(doc_format.format, 'docbook')
- pot_path = self.branch.domain_path(domain) / "C" / "release-notes.pot"
- self.assertTrue(pot_path.exists())
- self.addCleanup(os.remove, str(pot_path))
- self.assertIn('#: C/rnlookingforward.xml:11(para)', pot_path.read_text())
- res = utils.get_fig_stats(pot_path, doc_format=doc_format)
- self.assertEqual(len(res), 1)
- self.assertEqual(res[0]['path'], "figures/rnusers.nautilus.png")
-
- def test_generate_doc_potfile_mallard(self):
- """
- Test Mallard-style help (with itstool)
- """
- domain = Domain.objects.create(
- module=self.mod, name='release-notes', dtype='doc', directory='help_mallard'
- )
- potfile, errs = utils.generate_doc_pot_file(self.branch, domain)
- self.assertEqual(errs, [])
- doc_format = domain.doc_format(self.branch)
- self.assertEqual(potfile.name, 'release-notes.pot')
- self.assertEqual(doc_format.tool, 'itstool')
- self.assertEqual(doc_format.format, 'mallard')
- self.addCleanup(os.remove, str(potfile))
- self.assertIn('#: C/what-is.page:7', potfile.read_text())
- res = utils.get_fig_stats(potfile, doc_format=doc_format)
- self.assertEqual(len(res), 1)
- self.assertEqual(res[0]['path'], "figures/gnome-hello-logo.png")
- self.assertEqual(res[0]['hash'], "1ae47b7a7c4fbeb1f6bb72c0cf18d389")
-
@test_scratchdir
def test_insert_locale_in_linguas(self):
linguas_path = Path(settings.SCRATCHDIR) / 'git' / 'gnome-hello' / 'po' / 'LINGUAS'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]