small improvements of the version control systems handling:
[translate_toolkit.git] / convert / test_oo2xliff.py
blob4e9f2c4c33db33c80a5dd782137e6b24dad0c362
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 from translate.convert import test_oo2po
5 from translate.convert import oo2xliff
6 from translate.convert import xliff2oo
7 from translate.convert import test_convert
8 from translate.misc import wStringIO
9 from translate.storage import xliff
10 from translate.storage import oo
11 import os
13 class TestOO2XLIFF(test_oo2po.TestOO2PO):
14 target_filetype = xliff.xlifffile
15 conversion_module = oo2xliff
16 conversion_class = oo2xliff.oo2xliff
18 def test_msgid_bug_error_address(self):
19 pass
21 class TestOO2POCommand(test_convert.TestConvertCommand, TestOO2XLIFF):
22 """Tests running actual oo2xliff commands on files"""
23 convertmodule = oo2xliff
25 def test_help(self):
26 """tests getting help"""
27 options = test_convert.TestConvertCommand.test_help(self)
28 options = self.help_check(options, "--source-language=LANG")
29 options = self.help_check(options, "--language=LANG")
30 options = self.help_check(options, "--duplicates=DUPLICATESTYLE")
31 options = self.help_check(options, "--multifile=MULTIFILESTYLE")
32 options = self.help_check(options, "--nonrecursiveinput", last=True)
34 def test_preserve_filename(self):
35 """Ensures that the filename is preserved."""
36 oosource = r'svx source\dialog\numpages.src 0 string RID_SVXPAGE_NUM_OPTIONS STR_BULLET 0 en-US Character 20050924 09:13:58'
37 self.create_testfile("snippet.sdf", oosource)
38 oofile = oo.oofile(self.open_testfile("snippet.sdf"))
39 assert oofile.filename.endswith("snippet.sdf")
40 oofile.parse(oosource)
41 assert oofile.filename.endswith("snippet.sdf")
43 def test_simple_xlf(self):
44 """tests the simplest possible conversion to a xlf file"""
45 oosource = r'svx source\dialog\numpages.src 0 string RID_SVXPAGE_NUM_OPTIONS STR_BULLET 0 en-US Character 20050924 09:13:58'
46 self.create_testfile("simple.oo", oosource)
47 self.run_command("simple.oo", "simple.xlf", lang="ku", nonrecursiveinput=True)
48 pofile = self.target_filetype(self.open_testfile("simple.xlf"))
49 poelement = self.singleelement(pofile)
50 assert poelement.source == "Character"
51 assert poelement.target == ""
53 def test_simple_po(self):
54 """tests the simplest possible conversion to a po file"""
55 oosource1 = r'svx source\dialog\numpages.src 0 string RID_SVXPAGE_NUM_OPTIONS STR_BULLET 0 en-US Character 20050924 09:13:58'
56 oosource2 = r'svx source\dialog\numpages.src 0 string RID_SVXPAGE_NUM_OPTIONS STR_BULLET 0 ku Karakter 20050924 09:13:58'
57 self.create_testfile("simple.oo", oosource1 + "\n" + oosource2)
58 self.run_command("simple.oo", "simple.po", lang="ku", nonrecursiveinput=True)
59 pofile = self.target_filetype(self.open_testfile("simple.po"))
60 poelement = self.singleelement(pofile)
61 assert poelement.source == "Character"
62 assert poelement.target == "Karakter"
64 def test_onefile_nonrecursive(self):
65 """tests the --multifile=onefile option and make sure it doesn't produce a directory"""
66 oosource = r'svx source\dialog\numpages.src 0 string RID_SVXPAGE_NUM_OPTIONS STR_BULLET 0 en-US Character 20050924 09:13:58'
67 self.create_testfile("simple.oo", oosource)
68 self.run_command("simple.oo", "simple.xlf", lang="ku", multifile="onefile")
69 assert os.path.isfile(self.get_testfilename("simple.xlf"))