def test_existent_full_disk_path_is_returned(self):
     disk_path = "/dev/sda"
     self.mock_existence_of_disk(disk_path)
     self.assertEqual(
         disk_path,
         cc_mounts.sanitize_devname(disk_path, lambda x: None, mock.Mock()),
     )
Ejemplo n.º 2
0
 def test_existent_full_disk_path_is_returned(self):
     disk_path = '/dev/sda'
     self.mock_existence_of_disk(disk_path)
     self.assertEqual(disk_path,
                      cc_mounts.sanitize_devname(disk_path,
                                                 lambda x: None,
                                                 mock.Mock()))
Ejemplo n.º 3
0
 def test_existent_disk_name_returns_full_path(self):
     disk_name = 'sda'
     disk_path = '/dev/' + disk_name
     self.mock_existence_of_disk(disk_path)
     self.assertEqual(
         disk_path,
         cc_mounts.sanitize_devname(disk_name, lambda x: None, mock.Mock()))
Ejemplo n.º 4
0
 def test_device_aliases_remapping(self):
     disk_path = '/dev/sda'
     self.mock_existence_of_disk(disk_path)
     self.assertEqual(
         disk_path,
         cc_mounts.sanitize_devname('mydata', lambda x: None, mock.Mock(),
                                    {'mydata': disk_path}))
Ejemplo n.º 5
0
 def test_nth_partition_returned_if_requested(self):
     disk_name, partition_part = '/dev/sda', '3'
     actual_partition_path = disk_name + partition_part
     self.mock_existence_of_partition(disk_name, partition_part)
     self.assertEqual(
         actual_partition_path,
         cc_mounts.sanitize_devname('ephemeral0.3', lambda x: disk_name,
                                    mock.Mock()))
Ejemplo n.º 6
0
 def test_existent_meta_disk_is_returned(self):
     actual_disk_path = '/dev/sda'
     self.mock_existence_of_disk(actual_disk_path)
     self.assertEqual(
         actual_disk_path,
         cc_mounts.sanitize_devname('ephemeral0',
                                    lambda x: actual_disk_path,
                                    mock.Mock()))
Ejemplo n.º 7
0
 def test_existent_meta_partition_with_p_is_returned(self):
     disk_name, partition_part = '/dev/sda', 'p1'
     actual_partition_path = disk_name + partition_part
     self.mock_existence_of_partition(disk_name, partition_part)
     self.assertEqual(
         actual_partition_path,
         cc_mounts.sanitize_devname('ephemeral0.1', lambda x: disk_name,
                                    mock.Mock()))
Ejemplo n.º 8
0
 def test_existent_meta_disk_is_returned(self):
     actual_disk_path = '/dev/sda'
     self.mock_existence_of_disk(actual_disk_path)
     self.assertEqual(
         actual_disk_path,
         cc_mounts.sanitize_devname('ephemeral0',
                                    lambda x: actual_disk_path,
                                    mock.Mock()))
 def test_existent_disk_but_missing_partition_returns_none(self):
     disk_path = "/dev/sda"
     self.mock_existence_of_disk(disk_path)
     self.assertIsNone(
         cc_mounts.sanitize_devname(
             "ephemeral0.1", lambda x: disk_path, mock.Mock()
         )
     )
Ejemplo n.º 10
0
 def test_existent_disk_name_returns_full_path(self):
     disk_name = 'sda'
     disk_path = '/dev/' + disk_name
     self.mock_existence_of_disk(disk_path)
     self.assertEqual(disk_path,
                      cc_mounts.sanitize_devname(disk_name,
                                                 lambda x: None,
                                                 mock.Mock()))
Ejemplo n.º 11
0
 def test_first_partition_returned_if_existent_disk_is_partitioned(self):
     disk_name, partition_part = '/dev/sda', '1'
     actual_partition_path = disk_name + partition_part
     self.mock_existence_of_partition(disk_name, partition_part)
     self.assertEqual(
         actual_partition_path,
         cc_mounts.sanitize_devname('ephemeral0',
                                    lambda x: disk_name,
                                    mock.Mock()))
Ejemplo n.º 12
0
 def test_first_partition_returned_if_existent_disk_is_partitioned(self):
     disk_name, partition_part = "/dev/sda", "1"
     actual_partition_path = disk_name + partition_part
     self.mock_existence_of_partition(disk_name, partition_part)
     self.assertEqual(
         actual_partition_path,
         cc_mounts.sanitize_devname("ephemeral0", lambda x: disk_name,
                                    mock.Mock()),
     )
Ejemplo n.º 13
0
 def test_existent_meta_partition_with_p_is_returned(self):
     disk_name, partition_part = '/dev/sda', 'p1'
     actual_partition_path = disk_name + partition_part
     self.mock_existence_of_partition(disk_name, partition_part)
     self.assertEqual(
         actual_partition_path,
         cc_mounts.sanitize_devname('ephemeral0.1',
                                    lambda x: disk_name,
                                    mock.Mock()))
Ejemplo n.º 14
0
 def test_transformer_returning_none_returns_none(self):
     self.assertIsNone(
         cc_mounts.sanitize_devname(
             'ephemeral0', lambda x: None, mock.Mock()))
Ejemplo n.º 15
0
 def test_missing_sys_returns_none(self):
     disk_path = '/dev/sda'
     self._makedirs(disk_path)
     self.assertIsNone(
         cc_mounts.sanitize_devname(disk_path, None, mock.Mock()))
Ejemplo n.º 16
0
 def test_missing_device_returns_none(self):
     self.assertIsNone(
         cc_mounts.sanitize_devname('/dev/sda', None, mock.Mock()))
Ejemplo n.º 17
0
 def test_transformer_returning_none_returns_none(self):
     self.assertIsNone(
         cc_mounts.sanitize_devname('ephemeral0', lambda x: None,
                                    mock.Mock()))
Ejemplo n.º 18
0
 def test_network_device_returns_network_device(self):
     disk_path = 'netdevice:/path'
     self.assertEqual(
         disk_path, cc_mounts.sanitize_devname(disk_path, None,
                                               mock.Mock()))
Ejemplo n.º 19
0
 def test_missing_device_returns_none(self):
     self.assertIsNone(
         cc_mounts.sanitize_devname('/dev/sda', None, mock.Mock()))
Ejemplo n.º 20
0
 def test_missing_sys_returns_none(self):
     disk_path = '/dev/sda'
     self._makedirs(disk_path)
     self.assertIsNone(
         cc_mounts.sanitize_devname(disk_path, None, mock.Mock()))
Ejemplo n.º 21
0
 def test_existent_disk_but_missing_partition_returns_none(self):
     disk_path = '/dev/sda'
     self.mock_existence_of_disk(disk_path)
     self.assertIsNone(
         cc_mounts.sanitize_devname(
             'ephemeral0.1', lambda x: disk_path, mock.Mock()))