def test_read_on_memory(self): ce = CacheEntry(None, None, 0.0, lambda x:x) ce.write(DataFile('deadbeaf', '')) d = ce.read() def xxx(f): self.assertEquals(f.read(), 'deadbeaf') d.addCallback(xxx) return d
def test_read_on_miss(self): ce = CacheEntry('http://example.com/foo/bar/data', 'test', 0.0, lambda x:x) d = ce.read() def xxx(f): self.assertEquals(ce.datafile.read(), 'deadbeaf') d.addCallback(xxx) f = DataFile('deadbeaf', '', 'text/plain') ce.write(f) return d