Exemplo n.º 1
0
    def test_updating_filename_cleans_compression(self):
        uncompressed_fn = os.path.join(self.fixtures_dir, 'base.txt')
        compressed_fn = os.path.join(self.fixtures_dir, 'base.txt.gz')
        self.options['filename'] = uncompressed_fn

        obj = Object(self.options)
        metadata = obj.to_metadata()
        self.assertIsNone(metadata.get('compressed'))

        obj.update('filename', compressed_fn)
        metadata = obj.to_metadata()
        self.assertEqual(metadata['compressed'], True)

        obj.update('filename', uncompressed_fn)
        metadata = obj.to_metadata()
        self.assertIsNone(metadata.get('compressed'))
Exemplo n.º 2
0
 def test_update_object_raises_error_if_invalid_option(self):
     obj = Object(self.options)
     with self.assertRaises(ValueError):
         obj.update('target-path', '/')  # invalid in raw mode
     with self.assertRaises(ValueError):
         obj['target-path']
Exemplo n.º 3
0
 def test_can_update_object(self):
     obj = Object(self.options)
     self.assertEqual(obj['target'], '/dev/sda')
     obj.update('target', '/dev/sdb')
     self.assertEqual(obj['target'], '/dev/sdb')