Package Pootle :: Package storage :: Module test_merge
[show private | hide private]
[frames | no frames]

Module Pootle.storage.test_merge

Function Summary
  test_interface()
Test conformance to the API interface.
  test_SimpleMerger()
We will need a template:

Function Details

test_interface()

Test conformance to the API interface.

Poor man's alternative to zope.interface.
>>> from Pootle.storage.api import validateModule
>>> import Pootle.storage.merge
>>> validateModule(Pootle.storage.merge)

test_SimpleMerger()

We will need a template:
>>> from Pootle.storage.merge import SimpleMerger
>>> from Pootle.storage.memory import TranslationStore
>>> template = TranslationStore('template', None)
>>> tr1 = template.makeunit([('%d chair', '%d Stuhl'),
...                          ('%d chairs', '%d Stuehle')])
>>> tr2 = template.makeunit([('foo', 'bar')])
>>> tr3 = template.makeunit([('old', 'old')])
>>> tr4 = template.makeunit([('new', 'new')])
>>> template.fill([tr1, tr2, tr3, tr4])
And a translation object:
>>> translation = TranslationStore('template', None)
>>> tr1 = translation.makeunit([('foo', 'not bar')])
>>> tr2 = translation.makeunit([('%d chair', '%d stool'),
...                             ('%d chairs', '%d stools')])
>>> tr3 = template.makeunit([('new', '')]) # untranslated
>>> translation.fill([tr1, tr2, tr3])
Let's do the merge:
>>> from Pootle.storage.merge import SimpleMerger
>>> SimpleMerger().merge(translation, template)
>>> [t.trans for t in translation] #doctest: +NORMALIZE_WHITESPACE
[[('%d chair', '%d stool'), ('%d chairs', '%d stools')],
 [('foo', 'not bar')],
 [('old', 'old')],
 [('new', 'new')]]

Generated by Epydoc 2.1 on Tue Aug 22 04:29:46 2006 http://epydoc.sf.net