def test_deleteObject(self): """ Deleting an object is an update """ ppd = PPD() ppd.addObject({'foo': 'bar'}) self.fakeLastUpdated(ppd, 12.2) ppd.deleteObject(0) self.assertNotEqual(ppd.last_updated(), 12.2)
def test_deleteObject(self): """ You can delete objects by id """ i = PPD() id1 = i.addObject({'foo': 'bar'}) i.deleteObject(id1) objects = i.listObjects() self.assertEqual(len(objects), 0, "Should have deleted the object")
def test_deleteFile(self): """ When you delete a file's metadata, the content is also deleted. """ i = PPD() fh = StringIO('\x00\x01Hey\xff') obj_id = i.addFile(fh, 'something.exe', {'hey': 'ho'}) obj = i.getObject(obj_id) file_id = obj['_file_id'] i.deleteObject(obj_id) self.assertRaises(KeyError, i.getFileContents, file_id)
def test_multipleUsers(self): """ Two instances of PPD using the same database should see the other guy's changes all the time. """ dbfile = self.mktemp() a = PPD(dbfile) b = PPD(dbfile) a.addObject({'foo': 'bar'}) self.assertEqual(len(b.listObjects()), 1, "Adding should be concurrent") a.updateObjects({'boo': 'hoo'}) self.assertEqual(len(b.listObjects({'boo': 'hoo'})), 1, "Updating should be concurrent") a.deleteObject(1) self.assertEqual(len(b.listObjects()), 0, "Deleting should be concurrent") a.addFile(StringIO('foo'), 'foo.txt', {}) self.assertEqual(len(b.listObjects()), 1, "Adding files should be concurrent")