'Validate pool capacity calculations'

def test_update_volume_stats_provisioning(self):

    fake_pool = copy.deepcopy(eseries_fake.STORAGE_POOL)
    self.library._get_storage_pools = mock.Mock(return_value=[fake_pool])
    self.mock_object(self.library, '_ssc_stats', {fake_pool['volumeGroupRef']: {self.library.THIN_UQ_SPEC: True}})
    self.library.configuration = mock.Mock()
    reserved_pct = 5
    over_subscription_ratio = 1.0
    self.library.configuration.max_over_subscription_ratio = over_subscription_ratio
    self.library.configuration.reserved_percentage = reserved_pct
    total_gb = (int(fake_pool['totalRaidedSpace']) / units.Gi)
    used_gb = (int(fake_pool['usedSpace']) / units.Gi)
    free_gb = (total_gb - used_gb)
    self.library._update_volume_stats()
    self.assertEqual(1, len(self.library._stats['pools']))
    pool_stats = self.library._stats['pools'][0]
    self.assertEqual(fake_pool['label'], pool_stats.get('pool_name'))
    self.assertEqual(reserved_pct, pool_stats['reserved_percentage'])
    self.assertEqual(over_subscription_ratio, pool_stats['max_over_subscription_ratio'])
    self.assertEqual(total_gb, pool_stats.get('total_capacity_gb'))
    self.assertEqual(used_gb, pool_stats.get('provisioned_capacity_gb'))
    self.assertEqual(free_gb, pool_stats.get('free_capacity_gb'))
