Ejemplo n.º 1
0
    def test_counter_quota_usage_is_right_after_recalculation(self):
        quota = self.parent.quotas.get(name=self.quota_field)
        quota.usage = 3
        quota.save()

        silent_call('recalculatequotas')

        quota = self.parent.quotas.get(name=self.quota_field)
        self.assertEqual(quota.usage, 1)
Ejemplo n.º 2
0
    def test_limit_aggregator_recalculation(self):
        limit_value = 10
        for child in self.children:
            quota = child.quotas.get(name=self.child_quota_field)
            quota.limit = limit_value
            quota.save()
        # set quota as wrong number to test recalculation
        for parent in self.parents:
            parent.set_quota_limit(self.parent_quota_field, 666)
        self.grandparent.set_quota_limit(self.grandparent_quota_field, 1232)

        silent_call('recalculatequotas')

        for parent in self.parents:
            quota = parent.quotas.get(name=self.parent_quota_field)
            self.assertEqual(quota.usage, limit_value)

        quota = self.grandparent.quotas.get(name=self.grandparent_quota_field)
        self.assertEqual(quota.usage, limit_value * len(self.children))