Ticket #1510: 1510-test.diff

File 1510-test.diff, 1.3 KB (added by warner, at 2011-08-27T20:44:38Z)

unit test to exercise the failure

  • src/allmydata/test/test_mutable.py

    diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py
    index e6eea1e..c20c0cc 100644
    a b class Interoperability(GridTestMixin, unittest.TestCase, testutil.ShouldFailMixi 
    35773577        d = n.download_best_version()
    35783578        d.addCallback(self.failUnlessEqual, self.sdmf_old_contents)
    35793579        return d
     3580
     3581class DifferentEncoding(unittest.TestCase):
     3582    def setUp(self):
     3583        self._storage = s = FakeStorage()
     3584        self.nodemaker = make_nodemaker(s)
     3585
     3586    def test_new_encoding(self):
     3587        # create a file with 3-of-20, then modify it with a client configured
     3588        # to do 3-of-10. I saw a failure here.
     3589        self.nodemaker.default_encoding_parameters["n"] = 20
     3590        d = self.nodemaker.create_mutable_file("old contents")
     3591        def _created(n):
     3592            filecap = n.get_cap().to_string()
     3593            del n # we want a new object, not the cached one
     3594            self.nodemaker.default_encoding_parameters["n"] = 10
     3595            n2 = self.nodemaker.create_from_cap(filecap)
     3596            return n2
     3597        d.addCallback(_created)
     3598        def modifier(old_contents, servermap, first_time):
     3599            return "new contents"
     3600        d.addCallback(lambda n: n.modify(modifier))
     3601        return d
     3602