示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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''))
示例#4
0
    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)
示例#5
0
    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")
示例#6
0
    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)