Exemple #1
0
 def _save_per_client_data(self):
     data = {
         'keys': self._client_keys.as_dict(),
         'generations': [g.as_dict() for g in self._generations],
     }
     blob = obnamlib.serialise_object(data)
     filename = self._get_filename()
     self._fs.overwrite_file(filename, blob)
Exemple #2
0
    def _save_data(self):
        blob = obnamlib.serialise_object(self._data)

        bag_store = obnamlib.BagStore()
        bag_store.set_location(self._fs, self.get_dirname())

        blob_store = obnamlib.BlobStore()
        blob_store.set_bag_store(bag_store)
        blob_store.put_well_known_blob(self._well_known_blob, blob)
Exemple #3
0
 def _save_per_client_data(self):
     data = {
         'whole-file-checksum': self._checksum_algorithm,
         'keys': self._client_keys.as_dict(),
         'generations': [g.as_dict() for g in self._generations],
     }
     blob = obnamlib.serialise_object(data)
     blob_store = self._get_blob_store()
     blob_store.put_well_known_blob(self._well_known_blob, blob)
Exemple #4
0
 def _save_per_client_data(self):
     data = {
         'whole-file-checksum': self._checksum_algorithm,
         'keys': self._client_keys.as_dict(),
         'generations': [g.as_dict() for g in self._generations],
     }
     blob = obnamlib.serialise_object(data)
     blob_store = self._get_blob_store()
     blob_store.put_well_known_blob(self._well_known_blob, blob)
Exemple #5
0
    def _save_data(self):
        assert self._data is not None
        blob = obnamlib.serialise_object(self._data)

        bag_store = obnamlib.BagStore()
        bag_store.set_location(self._fs, self.get_dirname())

        blob_store = obnamlib.BlobStore()
        blob_store.set_bag_store(bag_store)
        blob_store.put_well_known_blob(self._well_known_blob, blob)
 def test_handles_more_complicated_object(self):
     obj = {
         'zero': 0,
         'true': True,
         'string': 'abc\0def',
         'list': ['foo'],
         'dict': {
             'one': 0,
         },
     }
     blob = obnamlib.serialise_object(obj)
     self.assertEqual(obnamlib.deserialise_object(blob), obj)
Exemple #7
0
 def test_handles_more_complicated_object(self):
     obj = {
         'zero': 0,
         'true': True,
         'string': 'abc\0def',
         'list': ['foo'],
         'dict': {
             'one': 0,
         },
     }
     blob = obnamlib.serialise_object(obj)
     self.assertEqual(obnamlib.deserialise_object(blob), obj)
Exemple #8
0
    def _save_data(self):
        root = {
            'checksum_algorithm': self._checksum_name,
            'by_chunk_id': self._by_chunk_id_tree.commit(),
            'by_checksum': self._by_checksum_tree.commit(),
            'used_by': self._used_by_tree.commit(),
        }

        blob = obnamlib.serialise_object(root)

        bag_store = obnamlib.BagStore()
        bag_store.set_location(self._fs, self.get_dirname())

        blob_store = obnamlib.BlobStore()
        blob_store.set_bag_store(bag_store)
        blob_store.put_well_known_blob(self._well_known_blob, blob)
Exemple #9
0
    def _save_data(self):
        root = {
            'checksum_algorithm': self._checksum_name,
            'by_chunk_id': self._by_chunk_id_tree.commit(),
            'by_checksum': self._by_checksum_tree.commit(),
            'used_by': self._used_by_tree.commit(),
        }

        blob = obnamlib.serialise_object(root)

        bag_store = obnamlib.BagStore()
        bag_store.set_location(self._fs, self.get_dirname())

        blob_store = obnamlib.BlobStore()
        blob_store.set_bag_store(bag_store)
        blob_store.put_well_known_blob(self._well_known_blob, blob)
 def test_handles_dict(self):
     blob = obnamlib.serialise_object({'foo': 'bar'})
     self.assertEqual(obnamlib.deserialise_object(blob), {'foo': 'bar'})
 def test_handles_list(self):
     blob = obnamlib.serialise_object([1, 2, 3])
     self.assertEqual(obnamlib.deserialise_object(blob), [1, 2, 3])
 def test_handles_empty_string(self):
     blob = obnamlib.serialise_object('')
     self.assertEqual(obnamlib.deserialise_object(blob), '')
 def test_handles_None(self):
     blob = obnamlib.serialise_object(None)
     self.assertEqual(obnamlib.deserialise_object(blob), None)
Exemple #14
0
 def test_handles_a_boolean_false(self):
     blob = obnamlib.serialise_object(False)
     self.assertEqual(obnamlib.deserialise_object(blob), False)
Exemple #15
0
 def _put_dir_obj(self, dir_obj):
     dir_obj.set_immutable()
     blob = obnamlib.serialise_object(dir_obj.as_dict())
     return self._blob_store.put_blob(blob)
Exemple #16
0
 def _put_dir_obj(self, dir_obj):
     dir_obj.set_immutable()
     blob = obnamlib.serialise_object(dir_obj.as_dict())
     return self._blob_store.put_blob(blob)
Exemple #17
0
 def test_handles_an_int(self):
     blob = obnamlib.serialise_object(42)
     self.assertEqual(obnamlib.deserialise_object(blob), 42)
Exemple #18
0
 def test_handles_dict(self):
     blob = obnamlib.serialise_object({'foo': 'bar'})
     self.assertEqual(obnamlib.deserialise_object(blob), {'foo': 'bar'})
Exemple #19
0
 def test_handles_empty_dict(self):
     blob = obnamlib.serialise_object({})
     self.assertEqual(obnamlib.deserialise_object(blob), {})
Exemple #20
0
 def test_handles_list(self):
     blob = obnamlib.serialise_object([1, 2, 3])
     self.assertEqual(obnamlib.deserialise_object(blob), [1, 2, 3])
Exemple #21
0
 def test_handles_empty_string(self):
     blob = obnamlib.serialise_object('')
     self.assertEqual(obnamlib.deserialise_object(blob), '')
Exemple #22
0
 def test_handles_None(self):
     blob = obnamlib.serialise_object(None)
     self.assertEqual(obnamlib.deserialise_object(blob), None)
 def test_handles_empty_dict(self):
     blob = obnamlib.serialise_object({})
     self.assertEqual(obnamlib.deserialise_object(blob), {})
 def test_handles_an_int(self):
     blob = obnamlib.serialise_object(42)
     self.assertEqual(obnamlib.deserialise_object(blob), 42)
Exemple #25
0
def serialise_bag(bag):
    obj = {
        'bag-id': bag.get_id(),
        'blobs': [bag[i] for i in range(len(bag))],
    }
    return obnamlib.serialise_object(obj)
 def test_handles_a_boolean_true(self):
     blob = obnamlib.serialise_object(True)
     self.assertEqual(obnamlib.deserialise_object(blob), True)
Exemple #27
0
 def _save_data(self):
     assert self._data is not None
     blob = obnamlib.serialise_object(self._data)
     filename = self._get_filename()
     self._fs.overwrite_file(filename, blob)
 def test_handles_a_boolean_false(self):
     blob = obnamlib.serialise_object(False)
     self.assertEqual(obnamlib.deserialise_object(blob), False)
Exemple #29
0
def serialise_bag(bag):
    obj = {
        'bag-id': bag.get_id(),
        'blobs': [bag[i] for i in range(len(bag))],
    }
    return obnamlib.serialise_object(obj)
Exemple #30
0
 def test_handles_a_boolean_true(self):
     blob = obnamlib.serialise_object(True)
     self.assertEqual(obnamlib.deserialise_object(blob), True)