def test_existing(self):
     filename = os.path.join('tests', str(uuid.uuid4()) + '.test')
     with open(filename, 'w') as g:
         g.write('this file exists')
     self.assertTrue(recfile.exists(filename))
     self.assertTrue(hasattr(recfile.open(filename, "r"), 'read'))
     recfile.remove(filename, path='tests')
     self.assertFalse(recfile.exists(filename))
     self.assertRaises(IOError, recfile.remove, filename)
     self.assertRaises(IOError, recfile.open, filename, "r")
Example #2
0
 def testgeneration(self):
     for k in range(20):
         teststring = 'test%s' % k
         filename = os.path.join('tests', str(uuid.uuid4()) + '.test')
         with recfile.open(filename, "w") as g:
             g.write(teststring)
         self.assertEqual(recfile.open(filename, "r").read(), teststring)
         is_there = recfile.exists(filename)
         self.assertTrue(is_there)
         recfile.remove(filename)
         is_there = recfile.exists(filename)
         self.assertFalse(is_there)
Example #3
0
 def testgeneration(self):
     for k in range(20):
         teststring = 'test%s' % k
         filename = os.path.join('tests', str(uuid.uuid4()) + '.test')
         with recfile.open(filename, "w") as g:
             g.write(teststring)
         self.assertEqual(recfile.open(filename, "r").read(), teststring)
         is_there = recfile.exists(filename)
         self.assertTrue(is_there)
         recfile.remove(filename)
         is_there = recfile.exists(filename)
         self.assertFalse(is_there)
Example #4
0
 def test_existing(self):
     filename = os.path.join("tests", str(uuid.uuid4()) + ".test")
     with open(filename, "w") as g:
         g.write("this file exists")
     self.assertTrue(recfile.exists(filename))
     r = recfile.open(filename, "r")
     self.assertTrue(hasattr(r, "read"))
     r.close()
     recfile.remove(filename, path="tests")
     self.assertFalse(recfile.exists(filename))
     self.assertRaises(IOError, recfile.remove, filename)
     self.assertRaises(IOError, recfile.open, filename, "r")
Example #5
0
 def __getitem__(self, key):
     key = self.key_filter_in(key)
     if recfile.exists(key, path=self.folder):
         timestamp, value = pickle.load(recfile.open(key, "rb", path=self.folder))
         return value
     else:
         raise KeyError
Example #6
0
 def __getitem__(self, key):
     if recfile.exists(key, path=self.folder):
         timestamp, value = pickle.load(
             recfile.open(key, 'rb', path=self.folder))
         return value
     else:
         raise KeyError
Example #7
0
 def test_generation(self):
     for k in range(10):
         teststring = "test%s" % k
         filename = os.path.join("tests", str(uuid.uuid4()) + ".test")
         with recfile.open(filename, "w") as g:
             g.write(teststring)
         with recfile.open(filename, "r") as f:
             self.assertEqual(f.read(), teststring)
         is_there = recfile.exists(filename)
         self.assertTrue(is_there)
         recfile.remove(filename)
         is_there = recfile.exists(filename)
         self.assertFalse(is_there)
     for k in range(10):
         teststring = "test%s" % k
         filename = str(uuid.uuid4()) + ".test"
         with recfile.open(filename, "w", path="tests") as g:
             g.write(teststring)
         with recfile.open(filename, "r", path="tests") as f:
             self.assertEqual(f.read(), teststring)
         is_there = recfile.exists(filename, path="tests")
         self.assertTrue(is_there)
         recfile.remove(filename, path="tests")
         is_there = recfile.exists(filename, path="tests")
         self.assertFalse(is_there)
     for k in range(10):
         teststring = "test%s" % k
         filename = os.path.join("tests", str(uuid.uuid4()), str(uuid.uuid4()) + ".test")
         with recfile.open(filename, "w") as g:
             g.write(teststring)
         with recfile.open(filename, "r") as f:
             self.assertEqual(f.read(), teststring)
         is_there = recfile.exists(filename)
         self.assertTrue(is_there)
         recfile.remove(filename)
         is_there = recfile.exists(filename)
         self.assertFalse(is_there)
Example #8
0
 def __contains__(self, key):
     key = self.key_filter_in(key)
     return (key in self.file_locks) or recfile.exists(key,
                                                       path=self.folder)
Example #9
0
 def __contains__(self, key):
     return recfile.exists(key, path=self.folder)
Example #10
0
 def __getitem__(self, key):
     if recfile.exists(key, path=self.folder):
         timestamp, value = pickle.load(recfile.open(key, 'rb', path=self.folder))
         return value
     else:
         raise KeyError
Example #11
0
 def __contains__(self, key):
     key = self.key_filter_in(key)
     return (key in self.file_locks) or recfile.exists(key, path=self.folder)
Example #12
0
 def __contains__(self, key):
     return recfile.exists(key, path=self.folder)