124
124
uuid = get_uuid()
125
125
self.assertTrue(uuid and len(uuid) > 0)
127
class TestExpungeCache(unittest.TestCase):
129
def test_expunge_cache(self):
132
dirname = tempfile.mkdtemp('s-c-testsuite')
133
for name, content in [ ("foo-301", "status: 301"),
134
("foo-200", "status: 200"),
135
("foo-random", "random"),
137
fullpath = os.path.join(dirname, name)
138
open(fullpath, "w").write(content)
139
# set to 1970+1s time to ensure the cleaner finds it
140
os.utime(fullpath, (1,1))
141
res = subprocess.call(["../utils/expunge-cache.py", dirname])
143
self.assertEqual(res, 1)
145
res = subprocess.call(["../utils/expunge-cache.py",
147
"--by-unsuccessful-http-states",
149
self.assertFalse(os.path.exists(os.path.join(dirname, "foo-301")))
150
self.assertTrue(os.path.exists(os.path.join(dirname, "foo-200")))
151
self.assertTrue(os.path.exists(os.path.join(dirname, "foo-random")))
154
res = subprocess.call(["../utils/expunge-cache.py",
158
# now we expect the old file to be gone but the unknown one not to
160
self.assertFalse(os.path.exists(os.path.join(dirname, "foo-200")))
161
self.assertTrue(os.path.exists(os.path.join(dirname, "foo-random")))
128
164
if __name__ == "__main__":