~nskaggs/help-app/functional-test-template

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from unittest import TestCase

from translations.build import Translations


class HelpTestCase(TestCase):
    def __init__(self, *args):
        self.translations = Translations()
        TestCase.__init__(self, *args)

    def test_first_line_of_docs_is_title_line(self):
        po = self.translations.po
        self.assertTrue(po.gettextize(self.translations.documents))
        results = []
        for entry, first_line in po.pot_file_ob.find_title_lines():
            results += [entry.msgid == first_line]
        self.assertNotIn(False, results)

    def test_translated_filenames_in_markdown_links(self):
        po = self.translations.po
        for po_fn in po.langs:
            po.load_pofile(po_fn)
            pofile = po.langs[po_fn]['pofile']
            for entry in pofile.find_in_msgid('{filename}'):
                (link_msgid, link_msgstr) = \
                    pofile.find_link_in_markdown_message(entry)
                if [doc for doc in self.translations.documents.docs
                        if doc.endswith(link_msgid)]:
                    self.assertNotIn(link_msgid, link_msgstr)
                    self.assertEqual(1, len(link_msgstr))
                    self.assertIn(po.langs[po_fn]['gettext_code'],
                                  link_msgstr[0])