Ejemplo n.º 1
0
 def test_put_with_lease(self):
     blob = LocalFileBlob(os.path.join(TEST_FOLDER, 'foobar.blob'))
     input = (1, 2, 3)
     blob.delete()
     blob.put(input, lease_period=0.01)
     blob.lease(0.01)
     self.assertEqual(blob.get(), input)
Ejemplo n.º 2
0
 def test_lease_error(self):
     blob = LocalFileBlob(os.path.join(TEST_FOLDER, 'foobar.blob'))
     blob.delete()
     self.assertEqual(blob.lease(0.01), None)
Ejemplo n.º 3
0
 def test_get(self):
     blob = LocalFileBlob(os.path.join(TEST_FOLDER, 'foobar'))
     self.assertIsNone(blob.get())
Ejemplo n.º 4
0
 def test_delete(self):
     blob = LocalFileBlob(os.path.join(TEST_FOLDER, 'foobar'))
     blob.delete()
     with mock.patch('os.remove') as m:
         blob.delete()
         m.assert_called_once_with(os.path.join(TEST_FOLDER, 'foobar'))
 def test_put_without_lease(self):
     blob = LocalFileBlob(os.path.join(TEST_FOLDER, 'foobar.blob'))
     input = (1, 2, 3)
     blob.delete(silent=True)
     blob.put(input)
     self.assertEqual(blob.get(), input)
 def test_put_error(self):
     blob = LocalFileBlob(os.path.join(TEST_FOLDER, 'foobar'))
     with mock.patch('os.rename', side_effect=throw(Exception)):
         self.assertRaises(Exception, lambda: blob.put([1, 2, 3]))
 def test_get(self):
     blob = LocalFileBlob(os.path.join(TEST_FOLDER, 'foobar'))
     self.assertIsNone(blob.get(silent=True))
     self.assertRaises(Exception, lambda: blob.get())
     self.assertRaises(Exception, lambda: blob.get(silent=False))
 def test_delete(self):
     blob = LocalFileBlob(os.path.join(TEST_FOLDER, 'foobar'))
     blob.delete(silent=True)
     self.assertRaises(Exception, lambda: blob.delete())
     self.assertRaises(Exception, lambda: blob.delete(silent=False))