def test_get_max_seats_for_plan_returns_max_seats_for_plan(self, mock_cb): # Given plan_id = 'startup' expected_max_seats = 3 mock_cb.Plan.retrieve.return_value = MockChargeBeePlanResponse( expected_max_seats) # When max_seats = get_max_seats_for_plan(plan_id) # Then assert max_seats == expected_max_seats
def update_max_seats_if_plan_changed(sender, instance, *args, **kwargs): existing_object = None try: existing_object = sender.objects.get(pk=instance.pk) except sender.DoesNotExist: pass if instance.subscription_id and settings.ENABLE_CHARGEBEE: current_plan = get_plan_id_from_subscription(instance.subscription_id) if not existing_object or current_plan != existing_object.plan: instance.max_seats = get_max_seats_for_plan(current_plan) instance.plan = current_plan instance.organisation.reset_alert_status()
def update_plan(self, plan_id): self.cancellation_date = None self.plan = plan_id self.max_seats = get_max_seats_for_plan(plan_id) self.save()