示例#1
0
    def testGetLabIdByMachNone(self):
        dptDB = DOMProdTestDB(self.conn)

        hostName = 'foo.bar.com'
        expId = None

        cursor = MockCursor("LabMachNone")

        tmpName = hostName
        while True:
            qry = 'select lab_id from LabMachine where machine="' + tmpName + \
                '"'
            cursor.addExpectedExecute(qry, None)

            dot = tmpName.find('.')
            if dot < 0:
                break

            tmpName = tmpName[dot + 1:]

        id = dptDB.getLabIdByMachine(cursor, hostName)
        self.assertEqual(
            id, expId, "Expected getLabIdByName to return " + str(expId) +
            ", not " + str(id))

        cursor.verify()
示例#2
0
    def testGetLabIdByName(self):
        dptDB = DOMProdTestDB(self.conn)

        hostName = 'foo.bar.com'
        expId = 12345

        cursor = MockCursor("LabName")

        qry = 'select lab_id from Laboratory where name="' + hostName + '"'
        cursor.addExpectedExecute(qry, (expId, ))

        id = dptDB.getLabIdByName(cursor, hostName)
        self.assertEqual(
            id, expId, "Expected getLabIdByName to return " + str(expId) +
            ", not " + str(id))

        cursor.verify()
示例#3
0
    def testGetLabIdByMach(self):
        dptDB = DOMProdTestDB(self.conn)

        pieces = ['foo', 'bar', 'com']

        hostName = '.'.join(pieces)
        expId = 12345

        for i in range(len(pieces)):
            cursor = MockCursor("LabMach#" + str(i))

            n = 0
            tmpName = hostName
            while True:
                qry = 'select lab_id from LabMachine where machine="' + \
                    tmpName + '"'
                if n < i:
                    cursor.addExpectedExecute(qry, None)
                else:
                    cursor.addExpectedExecute(qry, (expId, ))
                    break

                n = n + 1

                dot = tmpName.find('.')
                if dot < 0:
                    break

                tmpName = tmpName[dot + 1:]

            id = dptDB.getLabIdByMachine(cursor, hostName)
            self.assertEqual(
                id, expId, "Expected getLabIdByName to return " + str(expId) +
                ", not " + str(id))

            cursor.verify()