Exemple #1
0
    def testGetEntriesIfHasMultiple(self):
        '''Tests whether model only shows each entry once'''
        newTag = "muha"
        e = ModelEntry(self.log, "test")
        e.description = "balbalb " + newTag
        e.tags.append(newTag)
        self.model.db.addEntry(e)
        results = self.model.getEntries(newTag)
        self.assertEqual(0, results["name"].__len__())
        self.assertEqual(0, results["description"].__len__())
        self.assertEqual(1, results["tag"].__len__())

        newName = "scheenae"
        e = ModelEntry(self.log, newName)
        e.description = "balbalb " + newName
        e.tags.append(newName)
        self.model.db.addEntry(e)
        results = self.model.getEntries(newName)
        self.assertEqual(1, results["name"].__len__())
        self.assertEqual(0, results["description"].__len__())
        self.assertEqual(0, results["tag"].__len__())
Exemple #2
0
    def testAddNew(self):
        '''Adds a new entry which did not exist before'''
        n = ModelEntry(self.log, "bikes")
        n.description = "These are bikes"
        n.tags.append("Yamaha")
        n.tags.append("Kawasaki")
        n.images[self.testImageName] = self.filehandle.getStreamFromFiles(
            self.testImageStream)
        n.files[self.testWordName] = self.filehandle.getStreamFromFiles(
            self.testWordStream)

        self.db.addEntry(n)

        rows = self.getAllRows(self.dbPath)
        self.assertTrue(self.containsEntry(rows, n))
Exemple #3
0
    def getEntryFromRowObject(self, data):
        '''Makes an entry of a row object. Sql db extracts usually row objects'''
        if data == None:
            return None

        s = data["name"].encode("ascii")
        e = ModelEntry(self.log, s)
        s = data["description"].encode("ascii")
        e.description = s
        e.tags = self.fileHandle.getFilesFromStream(bytearray(data["tags"]))
        e.images = self.fileHandle.getDictFilesFromStream(
            bytearray(data["images"]))
        e.files = self.fileHandle.getDictFilesFromStream(
            bytearray(data["files"]))
        return e