Exemplo n.º 1
0
    def setUp(self):
        DictionaryTest.setUp(self)

        builderClasses = DatabaseBuilder.getTableBuilderClasses(quiet=True)
        dictionaryBuilder = [cls for cls in builderClasses
            if cls.PROVIDES == self.table][0]

        contentBuilder = types.ClassType("SimpleDictBuilder",
            (DictionaryResultTest._ContentGenerator, dictionaryBuilder),
            {'content': self.INSTALL_CONTENT})

        self.builder = DatabaseBuilder(quiet=True, dbConnectInst=self.db,
            additionalBuilders=[contentBuilder], prefer=["SimpleDictBuilder"],
            rebuildExisting=True, noFail=False)
        self.builder.build(self.DICTIONARY)
        assert self.db.mainHasTable(self.DICTIONARY)

        self.dictionary = self.dictionaryClass(dbConnectInst=self.db,
            **self.DICTIONARY_OPTIONS)
Exemplo n.º 2
0
    def setUp(self):
        DictionaryTest.setUp(self)

        builderClasses = DatabaseBuilder.getTableBuilderClasses(quiet=True)
        dictionaryBuilder = [
            cls for cls in builderClasses if cls.PROVIDES == self.table
        ][0]

        contentBuilder = new.classobj(
            "SimpleDictBuilder",
            (DictionaryResultTest._ContentGenerator, dictionaryBuilder),
            {'content': self.INSTALL_CONTENT})

        self.builder = DatabaseBuilder(quiet=True,
                                       dbConnectInst=self.db,
                                       additionalBuilders=[contentBuilder],
                                       prefer=["SimpleDictBuilder"],
                                       rebuildExisting=True,
                                       noFail=False)
        self.builder.build(self.DICTIONARY)
        assert self.db.mainHasTable(self.DICTIONARY)

        self.dictionary = self.dictionaryClass(dbConnectInst=self.db,
                                               **self.DICTIONARY_OPTIONS)
Exemplo n.º 3
0
    BUILDER = builder.CEDICTBuilder
    OPTIONS = [{'enableFTS3': False},
        {'filePath': './test/downloads/CEDICT', 'fileType': '.gz'}]


class CEDICTGRBuilderTest(TableBuilderTest, unittest.TestCase):
    BUILDER = builder.CEDICTGRBuilder
    OPTIONS = [{'enableFTS3': False},
        {'filePath': './test/downloads/CEDICTGR', 'fileType': '.zip'}]


class HanDeDictBuilderTest(TableBuilderTest, unittest.TestCase):
    BUILDER = builder.HanDeDictBuilder
    OPTIONS = [{'enableFTS3': False},
        {'filePath': './test/downloads/HanDeDict', 'fileType': '.tar.bz2'}]


class CFDICTBuilderTest(TableBuilderTest, unittest.TestCase):
    BUILDER = builder.CFDICTBuilder
    OPTIONS = [{'enableFTS3': False},
        {'filePath': './test/downloads/CFDICT', 'fileType': '.zip'}]


# Generate default test classes for TableBuilder without special definitions
for builderClass in DatabaseBuilder.getTableBuilderClasses(
    resolveConflicts=False):
    testClassName = '%sTest' % builderClass.__name__
    if testClassName not in globals():
        globals()[testClassName] = types.ClassType(testClassName,
            (TableBuilderTest, unittest.TestCase), {'BUILDER': builderClass})
    del testClassName
Exemplo n.º 4
0
    BUILDER = builder.CEDICTBuilder
    OPTIONS = [{'enableFTS3': False},
        {'filePath': './test/downloads/CEDICT', 'fileType': '.gz'}]


class CEDICTGRBuilderTest(TableBuilderTest, unittest.TestCase):
    BUILDER = builder.CEDICTGRBuilder
    OPTIONS = [{'enableFTS3': False},
        {'filePath': './test/downloads/CEDICTGR', 'fileType': '.zip'}]


class HanDeDictBuilderTest(TableBuilderTest, unittest.TestCase):
    BUILDER = builder.HanDeDictBuilder
    OPTIONS = [{'enableFTS3': False},
        {'filePath': './test/downloads/HanDeDict', 'fileType': '.tar.bz2'}]


class CFDICTBuilderTest(TableBuilderTest, unittest.TestCase):
    BUILDER = builder.CFDICTBuilder
    OPTIONS = [{'enableFTS3': False},
        {'filePath': './test/downloads/CFDICT', 'fileType': '.zip'}]


# Generate default test classes for TableBuilder without special definitions
for builderClass in DatabaseBuilder.getTableBuilderClasses(
    resolveConflicts=False):
    testClassName = '%sTest' % builderClass.__name__
    if testClassName not in globals():
        globals()[testClassName] = types.ClassType(testClassName,
            (TableBuilderTest, unittest.TestCase), {'BUILDER': builderClass})
    del testClassName