def prepare_enterprise_offer(self, percentage_discount_value=100, enterprise_customer_name=None): benefit = EnterprisePercentageDiscountBenefitFactory( value=percentage_discount_value) if enterprise_customer_name is not None: condition = EnterpriseCustomerConditionFactory( enterprise_customer_name=enterprise_customer_name) else: condition = EnterpriseCustomerConditionFactory() enterprise_offer = EnterpriseOfferFactory(partner=self.partner, benefit=benefit, condition=condition) self.mock_enterprise_learner_api( learner_id=self.user.id, enterprise_customer_uuid=str(condition.enterprise_customer_uuid), course_run_id=self.course_run.id, ) self.mock_catalog_contains_course_runs( [self.course_run.id], condition.enterprise_customer_uuid, enterprise_customer_catalog_uuid=condition. enterprise_customer_catalog_uuid, ) return enterprise_offer
def _create_enterprise_offer(): """ Return the enterprise offer. """ return ConditionalOfferFactory.create( benefit_id=EnterprisePercentageDiscountBenefitFactory.create().id, condition_id=EnterpriseCustomerConditionFactory.create().id, )
def prepare_enterprise_offer(self, percentage_discount_value=100): Switch.objects.update_or_create(name=ENTERPRISE_OFFERS_SWITCH, defaults={'active': True}) benefit = EnterprisePercentageDiscountBenefitFactory(value=percentage_discount_value) condition = EnterpriseCustomerConditionFactory() EnterpriseOfferFactory(partner=self.partner, benefit=benefit, condition=condition) self.mock_enterprise_learner_api( learner_id=self.user.id, enterprise_customer_uuid=str(condition.enterprise_customer_uuid), course_run_id=self.course_run.id, ) self.mock_catalog_contains_course_runs( [self.course_run.id], condition.enterprise_customer_uuid, enterprise_customer_catalog_uuid=condition.enterprise_customer_catalog_uuid, )