Пример #1
0
 def testCreateAddSaveLoadGet(self):
     'Test that we can create, add to, save, unload, load, and get from a ScanDigestFile.'
     max = 25
     sdfile = ScanDigestFile(self.owner, url=self.url, location=self.location,
                             siginfo=self.siginfo)
     # Create
     sdfile.create(max)
     self.assertIsNotNone(sdfile._container)
     self.assertIsInstance(sdfile._container, ScanDigest)
     self.assertEqual(sdfile._container.maxcapacity, max)
     url = 'http://www.bluecornchipfanatics.com/bestnachocheese.cgi'
     size = 3452
     uo = UrlObject(url, size, nonce=self.name, hash='ea463b2cd1')
     # Add/Get
     sdfile.add(uo)
     self.assertTrue(sdfile.get(uo))
     # Save
     sdfile.save()
     self.assertTrue(os.path.isfile(sdfile.filename))
     # Unload
     sdfile.unload()
     self.assertFalse(sdfile._container)
     # Load
     loaded_file = sdfile.load()
     self.assertTrue(sdfile._container)
     self.assertEqual(sdfile, loaded_file)
     # Get
     self.assertTrue(sdfile.get(uo))
Пример #2
0
 def testCreate(self):
     'Test that a ScanDigest object is created when we call create.'
     max = 25
     sdfile = ScanDigestFile(self.owner, url=self.url, location=self.location)
     sdfile.create(max)
     self.assertIsNotNone(sdfile._container)
     self.assertIsInstance(sdfile._container, ScanDigest)
     self.assertEqual(sdfile._container.maxcapacity, max)