[damned-lies] Solidify Mallard help potfile test



commit b2faeb0085eacaab0f5a5b844ba898f9a078e200
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Feb 15 09:54:43 2014 +0100

    Solidify Mallard help potfile test

 .../help_mallard/C/figures/gnome-hello-logo.png    |  Bin 0 -> 3388 bytes
 stats/tests/help_mallard/C/figures/gnome-hello.png |  Bin 0 -> 9480 bytes
 stats/tests/help_mallard/C/index.page              |   40 ++++++++++++
 stats/tests/help_mallard/C/legal.xml               |    9 +++
 stats/tests/help_mallard/C/what-is.page            |   27 ++++++++
 stats/tests/help_mallard/Makefile.am               |   15 ++++
 stats/tests/help_mallard/gnome-help-itstool.pot    |   68 --------------------
 stats/tests/tests.py                               |   38 +++++++----
 8 files changed, 116 insertions(+), 81 deletions(-)
---
diff --git a/stats/tests/help_mallard/C/figures/gnome-hello-logo.png 
b/stats/tests/help_mallard/C/figures/gnome-hello-logo.png
new file mode 100644
index 0000000..b52af4b
Binary files /dev/null and b/stats/tests/help_mallard/C/figures/gnome-hello-logo.png differ
diff --git a/stats/tests/help_mallard/C/figures/gnome-hello.png 
b/stats/tests/help_mallard/C/figures/gnome-hello.png
new file mode 100644
index 0000000..90a4d26
Binary files /dev/null and b/stats/tests/help_mallard/C/figures/gnome-hello.png differ
diff --git a/stats/tests/help_mallard/C/index.page b/stats/tests/help_mallard/C/index.page
new file mode 100644
index 0000000..a3c5057
--- /dev/null
+++ b/stats/tests/help_mallard/C/index.page
@@ -0,0 +1,40 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      type="guide" style="task"
+      id="index">
+
+  <info>
+    <desc>Help for GNOME Hello.</desc>
+    <title type='link' role="trail"><media type="image" src="figures/gnome-hello-logo.png"/></title>
+    <title type='text'>GNOME Hello</title>
+    <revision version="0.1" date="2011-08-26" status="final"/>
+    <credit type="author">
+      <name>Milo Casagrande</name>
+      <email>milo ubuntu com</email>
+    </credit>
+    <credit type="author">
+      <name>Tiffany Antopolski</name>
+      <email>tiffany antopolski gmail com</email>
+    </credit>
+
+    <license>
+      <p>Creative Commons Share Alike 3.0</p>
+    </license>
+
+    <include href="legal.xml" xmlns="http://www.w3.org/2001/XInclude"; />
+  </info>
+
+  <title><media type="image" src="figures/gnome-hello-logo.png">GNOME Hello logo</media>GNOME Hello</title>
+  <section id="introduction">
+   <title>Introduction</title>
+  </section>
+
+  <section id="what" style="2column">
+    <title>It's a small world</title>
+  </section>
+
+  <section id="advanced">
+    <title>
+      Advanced
+    </title>
+  </section>
+</page>
diff --git a/stats/tests/help_mallard/C/legal.xml b/stats/tests/help_mallard/C/legal.xml
new file mode 100644
index 0000000..6f643be
--- /dev/null
+++ b/stats/tests/help_mallard/C/legal.xml
@@ -0,0 +1,9 @@
+<license xmlns="http://projectmallard.org/1.0/";
+         href="http://creativecommons.org/licenses/by-sa/3.0/us/";>
+<p>This work is licensed under a
+<link href="http://creativecommons.org/licenses/by-sa/3.0/us/";>Creative Commons
+Attribution-Share Alike 3.0 United States License</link>.</p>
+<p>As a special exception, the copyright holders give you permission to copy,
+modify, and distribute the example code contained in this document under the
+terms of your choosing, without restriction.</p>
+</license>
diff --git a/stats/tests/help_mallard/C/what-is.page b/stats/tests/help_mallard/C/what-is.page
new file mode 100644
index 0000000..fb55daf
--- /dev/null
+++ b/stats/tests/help_mallard/C/what-is.page
@@ -0,0 +1,27 @@
+<page xmlns="http://projectmallard.org/1.0/";
+  type="guide"
+  id="what-is">
+  
+  <info>
+    <link type="guide" xref="index#introduction"/>
+    <desc>Description of <app>GNOME Hello</app>.</desc>
+    <revision version="0.1" date="2009-08-01" status="final"/>
+    <credit type="author">
+      <name>Milo Casagrande</name>
+      <email>milo ubuntu com</email>
+    </credit>
+
+    <license>
+      <p>Creative Commons Share Alike 3.0</p>
+    </license>
+
+    <include href="legal.xml" xmlns="http://www.w3.org/2001/XInclude"; />
+  </info>
+
+  <title>What is <app>GNOME Hello</app></title>
+  
+  <p>
+    <app>GNOME Hello</app> is a very complex program, with many nice features and nice options.
+  </p>
+
+</page>
diff --git a/stats/tests/help_mallard/Makefile.am b/stats/tests/help_mallard/Makefile.am
new file mode 100644
index 0000000..55a37af
--- /dev/null
+++ b/stats/tests/help_mallard/Makefile.am
@@ -0,0 +1,15 @@
+ YELP_HELP_RULES@
+
+HELP_ID = gnome-hello
+
+HELP_MEDIA = figures/gnome-hello.png \
+            figures/gnome-hello-logo.png
+
+HELP_FILES = index.page \
+  what-is.page \
+  legal.xml
+
+
+HELP_LINGUAS = es fr
+
+-include $(top_srcdir)/git.mk
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index a4a6a3b..020b5b6 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -175,26 +175,38 @@ class ModuleTestCase(TestCase):
         self.assertIn('"%s"' % new_string, mail.outbox[0].body)
 
     def test_read_file_variable(self):
-        from stats.utils import search_variable_in_file
         file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "help_docbook", "Makefile.am")
-        var_content = search_variable_in_file(file_path, "DOC_INCLUDES")
+        var_content = utils.search_variable_in_file(file_path, "DOC_INCLUDES")
         self.assertEqual(var_content.split(), ['rnusers.xml', 'rnlookingforward.xml', '$(NULL)'])
 
-    def test_generate_doc_potfile(self):
-        from stats.utils import generate_doc_pot_file, get_fig_stats, DocFormat
-        # Docbook-style help
+    def test_generate_doc_potfile_docbook(self):
+        """
+        Test Docbook-style help
+        """
         help_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "help_docbook")
-        potfile, errs, doc_format = generate_doc_pot_file(help_path, 'release-notes', 'release-notes')
+        self.addCleanup(os.remove, os.path.join(help_path, 'C', "release-notes.pot"))
+        potfile, errs, doc_format = utils.generate_doc_pot_file(help_path, 'release-notes', 'release-notes')
+        self.assertEqual(doc_format.__dict__, {'tool': 'xml2po', 'format': 'docbook'})
         pot_path = os.path.join(help_path, "C", "release-notes.pot")
         self.assertTrue(os.access(pot_path, os.R_OK))
-        res = get_fig_stats(pot_path, doc_format=doc_format)
+        res = utils.get_fig_stats(pot_path, doc_format=doc_format)
         self.assertEqual(len(res), 1)
-        os.remove(pot_path)
-        # Mallard-style help (with itstool)
-        pot_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "help_mallard", 
"gnome-help-itstool.pot")
-        res = get_fig_stats(pot_path, doc_format=DocFormat(True, True))
-        self.assertEqual(len(res), 2)
-        self.assertEqual(res[0]['path'], "figures/gnome.png")
+        self.assertEqual(res[0]['path'], "figures/rnusers.nautilus.png")
+
+    def test_generate_doc_potfile_mallard(self):
+        """
+        Test Mallard-style help (with itstool)
+        """
+        help_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "help_mallard")
+        self.addCleanup(os.remove, os.path.join(help_path, 'C', 'gnome-hello.pot'))
+        potfile, errs, doc_format = utils.generate_doc_pot_file(help_path, 'gnome-hello', 'gnome-hello')
+        self.assertEqual(potfile, os.path.join(help_path, 'C', 'gnome-hello.pot'))
+        self.assertEqual(errs, [])
+        self.assertEqual(doc_format.__dict__, {'tool': 'itstool', 'format': 'mallard'})
+        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_http_pot(self):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]