コード例 #1
0
class PublicanUtilityTest(unittest.TestCase):
    def setUp(self):
        self.publican = PublicanUtility()

    def test_strippath(self):
        filename = self.publican.strip_path("./testfiles/pot/test.pot", "./testfiles/pot", '.pot')
        self.assertEqual(filename, "test")
        
    def test_potfiletojson(self):
        body, filename = self.publican.potfile_to_json("./testfiles/pot/test.pot", "./testfiles/pot")
        json_data = open('./testfiles/pot/test.json')
        result = json.loads(body)
        expect_json = json.load(json_data)
        self.assertEqual(result['name'], "test")
        self.assertEqual(result['textFlows'], expect_json['textFlows'])
        self.assertEqual(result['contentType'], "application/x-gettext")
        self.assertEqual(result['extensions'], expect_json['extensions'])

        json_data.close()

    def test_pofiletojson(self):
        body = self.publican.pofile_to_json("./testfiles/po/test.po")
        json_data = open('./testfiles/po/test.json')
        result = json.loads(body)
        expect_json = json.load(json_data)
        self.assertEqual(result['textFlowTargets'], expect_json['textFlowTargets'])
        self.assertEqual(result['extensions'], expect_json['extensions'])
        json_data.close()
    
    def test_msgidplural(self):
        body, filename = self.publican.potfile_to_json("./testfiles/test_plural.po", "./testfiles/po")
        json_data = open('./testfiles/msgid_plural.json')
        result = json.loads(body)
        expect_json = json.load(json_data)
        self.assertEqual(result['textFlows'], expect_json['textFlows'])
        json_data.close()

    def test_msgstrplural(self):
        body = self.publican.pofile_to_json("./testfiles/test_plural.po")
        json_data = open('./testfiles/msgstr_plural.json')
        result = json.loads(body)
        expect_json = json.load(json_data)
        self.assertEqual(result['textFlowTargets'], expect_json['textFlowTargets'])
        self.assertEqual(result['extensions'], expect_json['extensions'])
        json_data.close()
コード例 #2
0
class PublicanUtilityTest(unittest.TestCase):
    def setUp(self):
        self.publican = PublicanUtility()

    def test_strippath(self):
        filename = self.publican.strip_path("./testfiles/pot/test.pot", "./testfiles/pot", '.pot')
        self.assertEqual(filename, "test")

    """
コード例 #3
0
class PublicanUtilityTest(unittest.TestCase):
    def setUp(self):
        self.publican = PublicanUtility()

    def test_strippath(self):
        filename = self.publican.strip_path("./testfiles/pot/test.pot", "./testfiles/pot")
        self.assertEqual(filename, "test")
        
    def test_potfiletojson(self):
        body, filename = self.publican.potfile_to_json("./testfiles/pot/test.pot", "./testfiles/pot")
        expect = """{"lang": "en-US", "extensions": [{"comment": "SOME DESCRIPTIVE TITLE.\\nCopyright (C) YEAR Free Software Foundation, Inc.\\nFIRST AUTHOR <EMAIL@ADDRESS>, YEAR.\\n", "object-type": "po-header", "entries": [{"value": "PACKAGE VERSION", "key": "Project-Id-Version"}, {"value": "2001-02-09 01:25+0100", "key": "POT-Creation-Date"}, {"value": "YEAR-MO-DA HO:MI+ZONE", "key": "PO-Revision-Date"}, {"value": "FULL NAME <EMAIL@ADDRESS>", "key": "Last-Translator"}, {"value": "LANGUAGE <*****@*****.**>", "key": "Language-Team"}, {"value": "1.0", "key": "MIME-Version"}, {"value": "application/x-xml2pot; charset=UTF-8", "key": "Content-Type"}, {"value": "ENCODING", "key": "Content-Transfer-Encoding"}]}], "contentType": "application/x-gettext", "name": "test", "textFlows": [{"lang": "en-US", "content": "<title>Access Control Lists</title>", "extensions": [{"object-type": "comment", "value": "Tag: title", "space": "preserve"}, {"object-type": "pot-entry-header", "references": ["Acls.xml:8"], "flags": ["no-c-format"], "context": "", "extractedComment": ""}], "id": "782f49c4e93c32403ba0b51821b38b90", "revision": 1}]}"""
        self.assertEqual(expect, body)
        self.assertEqual(filename, "test")  

    def test_pofiletojson(self):
        body = self.publican.pofile_to_json("./testfiles/po/test.po")
        expect = """{"textFlowTargets": [{"content": "<title>\\u8bbf\\u95ee\\u5b58\\u53d6\\u63a7\\u5236\\u5217\\u8868</title>", "extensions": [{"object-type": "comment", "value": "Tag: title", "space": "preserve"}], "state": "Approved", "resId": "782f49c4e93c32403ba0b51821b38b90"}], "extensions": [{"comment": "translation of Acls.po to Traditional Chinese\\ntranslation of Acls.po to\\nCopyright (C) 2003, 2007 Free Software Foundation, Inc.\\n\\nSarah Wang <*****@*****.**>, 2003.\\nXi HUANG <*****@*****.**>, 2007.\\nChester Cheng <*****@*****.**>, 2007.", "object-type": "po-target-header", "entries": [{"value": "Acls", "key": "Project-Id-Version"}, {"value": "http://bugs.kde.org", "key": "Report-Msgid-Bugs-To"}, {"value": "2001-02-09 01:25+0100", "key": "POT-Creation-Date"}, {"value": "2007-07-11 14:49+1000", "key": "PO-Revision-Date"}, {"value": "Chester Cheng <*****@*****.**>", "key": "Last-Translator"}, {"value": "Traditional Chinese <*****@*****.**>", "key": "Language-Team"}, {"value": "1.0", "key": "MIME-Version"}, {"value": "text/plain; charset=UTF-8", "key": "Content-Type"}, {"value": "8bit", "key": "Content-Transfer-Encoding"}, {"value": "KBabel 1.11.4", "key": "X-Generator"}]}], "links": []}"""
        self.assertEqual(expect, body)
コード例 #4
0
 def setUp(self):
     self.publican = PublicanUtility()