コード例 #1
0
    def test_create_patch_foo_bad_patch_type(self):
        fpatch = BytesIO()

        with open('tests/files/foo/old', 'rb') as fold:
            with open('tests/files/foo/new', 'rb') as fnew:
                with self.assertRaises(detools.Error) as cm:
                    detools.create_patch(fold, fnew, fpatch, patch_type='bad')

                self.assertEqual(str(cm.exception), "Bad patch type 'bad'.")
コード例 #2
0
    def test_create_patch_foo_bad_compression(self):
        fpatch = BytesIO()

        with open('tests/files/foo/old', 'rb') as fold:
            with open('tests/files/foo/new', 'rb') as fnew:
                with self.assertRaises(detools.Error) as cm:
                    detools.create_patch(fold, fnew, fpatch, compression='bad')

                self.assertEqual(
                    str(cm.exception),
                    "Expected compression bz2, crle, heatshrink, lz4, lzma, "
                    "none or zstd, but got bad.")
コード例 #3
0
    def assert_create_patch(self, from_filename, to_filename, patch_filename,
                            **kwargs):
        fpatch = BytesIO()

        with open(from_filename, 'rb') as fold:
            with open(to_filename, 'rb') as fnew:
                detools.create_patch(fold, fnew, fpatch, **kwargs)

        actual = fpatch.getvalue()
        # open(patch_filename, 'wb').write(actual)

        with open(patch_filename, 'rb') as fpatch:
            expected = fpatch.read()

        self.assertEqual(actual, expected)
コード例 #4
0
    def test_create_patch_in_place_bad_memory_and_segment_size_ratio(self):
        fpatch = BytesIO()

        with open('tests/files/foo/old', 'rb') as fold:
            with open('tests/files/foo/new', 'rb') as fnew:
                with self.assertRaises(detools.Error) as cm:
                    detools.create_patch(fold,
                                         fnew,
                                         fpatch,
                                         patch_type='in-place',
                                         memory_size=3000,
                                         segment_size=501)

                self.assertEqual(
                    str(cm.exception),
                    "Memory size 3000 is not a multiple of segment size 501.")