def testconvert(self):
        self.converter=getConverter("coladdmasterdiffs/dict")(self.differences, "lilr601")
        self.converter.convert()
        rows=self.converter.getvalue()
        print ",\n".join(map(str, rows))
        result=[{'master: subversion': '72.2.0.2', 'name': 'GFS-kernel-debuginfo', 'source: subversion': 'not installed', 'source: name': 'lilr642', 'architecture': 'x86_64', 'source: version': 'not installed', 'id': 'id1', 'master: version': '2.6.9'},
{'master: subversion': '72.2.0.2', 'name': 'GFS-kernel-debuginfo', 'source: subversion': 'not installed', 'source: name': 'lilr602', 'architecture': 'x86_64', 'source: version': 'not installed', 'id': 'id2', 'master: version': '2.6.9'},
{'master: subversion': 'not installed', 'name': 'GFS-kernel-debuginfo', 'architecture': 'x86_64', 'source: name': 'lilr602', 'source: subversion': '80.9.el4_7.5.hotfix.1', 'source: version': '2.6.9', 'id': 'id1', 'master: version': 'not installed'},
{'master: subversion': 'not installed', 'name': 'GFS-kernel-largesmp', 'architecture': 'x86_64', 'source: name': 'lilr642', 'source: subversion': '80.9.el4_7.1', 'source: version': '2.6.9', 'id': 'id2', 'master: version': 'not installed'},
{'master: subversion': '80.9.el4_7.5.hotfix.1', 'name': 'GFS-kernel-largesmp', 'source: subversion': 'not installed', 'source: name': 'lilr642', 'architecture': 'x86_64', 'source: version': 'not installed', 'id': 'id1', 'master: version': '2.6.9'}
                ]
        self.assertEquals(rows, result)
def createConverter(source=None, master=None, category=None, where=None, convertertype="coladddiffs/dict"):
    cmdb=SoftwareCMDB(hostname=ComoonicsGlobals.mysqlserver, user=ComoonicsGlobals.mysqluser, password=ComoonicsGlobals.mysqlpassword, database=ComoonicsGlobals.mysqldatabase)
    ComoonicsGlobals.mylog.debug("searching for master %s with source %s" %(master, source))
    if category:
        dbsource=Source(dbhandle=cmdb.db)
        source=dbsource.getSourcesForCategory(category)
        ComoonicsGlobals.mylog.debug("got %u sources for category %s" %(len(source), category))
    if isinstance(source, basestring):
        source=[source]
    packages=cmdb.getPackages(source, master, None, 0, 0, where)
    differences=packages.differences()
    ComoonicsGlobals.mylog.debug("Searching for converter: %s" %convertertype)
    converter=getConverter(convertertype)(differences)
    ComoonicsGlobals.mylog.debug("Got converter: %s" %converter)
    return converter
 def testconvertcolnames(self):
     self.converter=getConverter("coladdmasterdiffs/dict")(self.differences, "lilr601")
     self.converter.convert()
     rescolnames=['source: name', 'name', 'architecture', 'master: version', 'master: subversion', 'source: version', 'source: subversion', "id"]
     colnames=self.converter.columnnames
     self.assertEquals(colnames, rescolnames)