def testAddEntry(self): '''Checks only if the right method of db is called''' entry = ModelEntry(self.log, "new entry") self.model.db.addEntry = MagicMock() self.model.addEntry(entry) self.model.db.addEntry.assert_called_with(entry)
def testUpdateEntryIfNotExists(self): '''Trys to update an entries tags and description''' n = ModelEntry(self.log, "bikes") self.db.updateEntry(n) rows = self.getAllRows(self.dbPath) self.assertFalse(self.containsEntry(rows, n))
def testAddExisting(self): '''Trys to add an existing entry''' n = ModelEntry(self.log, "buildings") self.db.addEntry(n) rows = self.getAllRows(self.dbPath) self.assertFalse(self.containsEntry(rows, n), "Entry has been added")
def testHasEntryNegative(self): '''Questioned entry does not exist''' n = ModelEntry(self.log, "bikes") self.assertFalse(self.db.hasEntry(n))
def testDeleteEntryAction(self): self.ctr.model.currentEntry = ModelEntry(self.log, "e1") self.ctr.deleteEntryAction() self.ctr.model.removeEntry.assert_called_once_with(self.ctr.model.currentEntry) self.ctr.view.removeEntry.assert_called_once_with(self.ctr.model.currentEntry)
def setUp(self): self.log = Log("testlog.txt") self.log.add = MagicMock() self.entry = ModelEntry(self.log, "testentry")