def test_user_can_change_flavor_to_flavor_with_less_ram_if_result_ram_quota_usage_is_less_then_ram_limit(self):
        self.client.force_authenticate(user=self.user)
        instance = self.admined_instance
        instance.cores = 5
        instance.save()
        membership = instance.cloud_project_membership
        membership.set_quota_usage('vcpu', instance.cores)
        membership.set_quota_limit('ram', instance.ram)
        membership.set_quota_limit('vcpu', instance.cores)
        membership.set_quota_limit('max_instances', 0)
        membership.set_quota_limit('storage', 0)

        new_flavor = factories.FlavorFactory(
            cloud=self.admined_instance.cloud_project_membership.cloud,
            disk=self.admined_instance.system_volume_size + 1,
            ram=instance.ram - 1,
        )
        data = {'flavor': self._get_flavor_url(new_flavor)}

        response = self.client.post(factories.InstanceFactory.get_url(self.admined_instance, action='resize'), data)

        self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED, response.data)
        reread_instance = Instance.objects.get(pk=self.admined_instance.pk)
        self.assertEqual(reread_instance.state, Instance.States.RESIZING_SCHEDULED,
                         'Instance should have been scheduled to resize')
dataset/ETHPy150Open opennode/nodeconductor/nodeconductor/iaas/tests/test_provisioning.py/InstanceApiPermissionTest.test_user_can_change_flavor_to_flavor_with_less_ram_if_result_ram_quota_usage_is_less_then_ram_limit/original