fix git support for v1.5.3 (or higher) by setting "--work-tree"
[translate_toolkit.git] / storage / test_tbx.py
blob11594d700950df6d61a90732b32db71eff4eed1f
1 #!/usr/bin/env python
3 from translate.storage import tbx
4 from translate.storage import test_base
6 class TestTBXUnit(test_base.TestTranslationUnit):
7 UnitClass = tbx.tbxunit
10 class TestTBXfile(test_base.TestTranslationStore):
11 StoreClass = tbx.tbxfile
12 def test_basic(self):
13 tbxfile = tbx.tbxfile()
14 assert tbxfile.units == []
15 tbxfile.addsourceunit("Bla")
16 assert len(tbxfile.units) == 1
17 newfile = tbx.tbxfile.parsestring(str(tbxfile))
18 print str(tbxfile)
19 assert len(newfile.units) == 1
20 assert newfile.units[0].source == "Bla"
21 assert newfile.findunit("Bla").source == "Bla"
22 assert newfile.findunit("dit") is None
24 def test_source(self):
25 tbxfile = tbx.tbxfile()
26 tbxunit = tbxfile.addsourceunit("Concept")
27 tbxunit.source = "Term"
28 newfile = tbx.tbxfile.parsestring(str(tbxfile))
29 print str(tbxfile)
30 assert newfile.findunit("Concept") is None
31 assert newfile.findunit("Term") is not None
33 def test_target(self):
34 tbxfile = tbx.tbxfile()
35 tbxunit = tbxfile.addsourceunit("Concept")
36 tbxunit.target = "Konsep"
37 newfile = tbx.tbxfile.parsestring(str(tbxfile))
38 print str(tbxfile)
39 assert newfile.findunit("Concept").target == "Konsep"