From bf5e682d71e086f351126129c2e586a80442c2bb Mon Sep 17 00:00:00 2001 From: meejah Date: Mon, 25 Oct 2021 13:17:46 -0600 Subject: [PATCH] test upgrade of main state works --- src/allmydata/test/test_storage_web.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/allmydata/test/test_storage_web.py b/src/allmydata/test/test_storage_web.py index d91242449..0b287d667 100644 --- a/src/allmydata/test/test_storage_web.py +++ b/src/allmydata/test/test_storage_web.py @@ -1145,6 +1145,22 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin): d.addBoth(_cleanup) return d + def test_deserialize_pickle(self): + """ + The crawler can read existing state from the old pickle format + """ + original_pickle = FilePath(__file__).parent().child("data").child("lease_checker.state") + test_pickle = FilePath("lease_checker.state") + with test_pickle.open("w") as local, original_pickle.open("r") as remote: + local.write(remote.read()) + + serial = _LeaseStateSerializer(test_pickle.path) + + # the (existing) state file should have been upgraded to JSON + self.assertNot(test_pickle.exists()) + self.assertTrue(test_pickle.siblingExtension(".json").exists()) + + class WebStatus(unittest.TestCase, pollmixin.PollMixin):