def test_getUnit(self): """getUnit() should return desired Translation object""" editor = dicteditor.Editor() editor.load("data/sampledict.dwa") oldCount = len(editor.getUnits()) self.assert_(editor.getUnit('du') != None)
def test_load(self): """Editor should load dictionary from file""" editor = dicteditor.Editor() self.assertEquals(len(editor.getUnits()), 0) editor.load("data/sampledict.dwa") self.assertEquals(len(editor.getUnits()), 7)
def test_unicode(self): """All the strings must be unicode objects""" editor = dicteditor.Editor() editor.load("data/sampledict.dwa") for unit in editor.getUnits()[:10]: for trans in unit.getTranslations().keys(): self.assertEquals(type(trans), type(u''))
def test_removeUnit(self): """removeUnit() should add new translation unit or update old one""" editor = dicteditor.Editor() editor.load("data/sampledict.dwa") oldCount = len(editor.getUnits()) unit = editor.getUnit('vienas') editor.removeUnit(unit) self.assertEquals(len(editor.getUnits()), oldCount - 1)
def test_save(self): """Editor should correctly write dictionary to disk""" editor = dicteditor.Editor() editor.load("data/sampledict.dwa") units = editor.getUnits() editor.save("data/__output.dwa") editor.load("data/__output.dwa") self.assertEquals(len(units), len(editor.getUnits())) os.unlink("data/__output.dwa")
def test_addUnit(self): """addUnit() should add new translation unit or update old one""" editor = dicteditor.Editor() editor.load("data/sampledict.dwa") oldCount = len(editor.getUnits()) newUnit = dicteditor.Translation() newUnit.setWord("test") newUnit.addTranslation("utiutiu") editor.addUnit(newUnit) self.assertEquals(len(editor.getUnits()), oldCount + 1)