Exemplo n.º 1
0
    def test_detach(self, mock_get_mountpoint, mock_rmtree):
        mock_get_mountpoint.return_value = self.fake_mountpoint
        volume_driver = driver.Local()
        volume_driver.detach(self.context, self.volmap)

        mock_get_mountpoint.assert_called_once_with(self.fake_uuid)
        mock_rmtree.assert_called_once_with(self.fake_mountpoint)
Exemplo n.º 2
0
    def test_bind_mount(self, mock_get_mountpoint):
        mock_get_mountpoint.return_value = self.fake_mountpoint
        volume_driver = driver.Local()
        source, destination = volume_driver.bind_mount(
            self.context, self.volmap)

        expected_file_path = self.fake_mountpoint + '/' + self.fake_uuid
        self.assertEqual(expected_file_path, source)
        self.assertEqual(self.fake_container_path, destination)
        mock_get_mountpoint.assert_called_once_with(self.fake_uuid)
Exemplo n.º 3
0
    def test_attach(self, mock_get_mountpoint, mock_ensure_tree):
        mock_get_mountpoint.return_value = self.fake_mountpoint
        volume_driver = driver.Local()

        with mock.patch('zun.volume.driver.open',
                        mock.mock_open()) as mock_open:
            volume_driver.attach(self.context, self.volume)

        expected_file_path = self.fake_mountpoint + '/' + self.fake_uuid
        mock_open.assert_called_once_with(expected_file_path, 'wb')
        mock_open().write.assert_called_once_with(self.fake_contents)
        mock_get_mountpoint.assert_called_once_with(self.fake_uuid)