def testReportDataWithDb(self):
        db = TestCaseDB(DEFAULT_DB_NAME)

        result = Parser.parse(self.fileContent)

        db.refreshCoverageData(1, result)

        result2 = db.getCoverageData(1)

        self.assertEqual(len(result), len(result2))

        for fileName in result.keys():
            self.assertTrue(fileName in result2.keys())

            covInfo1 = result[fileName]
            covInfo2 = result2[fileName]

            self.assertTrue(covInfo1.getAllLines(), covInfo2.getAllLines())
Beispiel #2
0
    # set environment for perforce
    if options.p4client:
        os.environ['P4CLIENT'] = options.p4client

    if options.p4passwd:
        os.environ['P4PASSWD'] = options.p4passwd

    if options.p4port:
        os.environ['P4PORT'] = options.p4port

    if options.p4user:
        os.environ['P4USER'] = options.p4user

    # initialize the database
    print ('Connect the database for test cases...')
    caseDB = TestCaseDB('casedb.sqlite')

    if options.init:
        print ('Initialize database...')
        caseDB.initDB()
        caseDB.addCase('Test Hello.py 1', 'hello.py')
        caseDB.addCase('Test Hello.py 2', 'hello.py')
        caseDB.addCase('Test Hello.py 3', 'hello.py')

    cases = caseDB.getCaseInfo()

    if not len(cases):
        print ("Can't find any cases in databases.")
        sys.exit(0)

    ticket = p4login(options.p4passwd)