  def testGetDisk(self, mock_get_operation, mock_list_disks):
    """Test that a disk is retrieved by its name, if existing."""
    mock_get_operation.return_value = gcp_mocks.MOCK_GCE_OPERATION_INSTANCES_GET
    mock_list_disks.return_value = gcp_mocks.MOCK_LIST_DISKS

    # Normal disk
    disk = gcp_mocks.FAKE_INSTANCE.GetDisk(gcp_mocks.FAKE_DISK.name)
    self.assertIsInstance(disk, compute.GoogleComputeDisk)
    self.assertEqual('fake-disk', disk.name)

    # Boot disk
    disk = gcp_mocks.FAKE_INSTANCE.GetDisk(gcp_mocks.FAKE_BOOT_DISK.name)
    self.assertIsInstance(disk, compute.GoogleComputeDisk)
    self.assertEqual('fake-boot-disk', disk.name)

    # Disk that's not attached to the instance
    with self.assertRaises(errors.ResourceNotFoundError):
      gcp_mocks.FAKE_INSTANCE.GetDisk('non-existent-disk')
Test that a disk is retrieved by its name, if existing.
tests/providers/gcp/internal/test_compute.py