def setUp(self): super(EnterpriseCustomerConditionTests, self).setUp() Switch.objects.update_or_create(name=ENTERPRISE_OFFERS_SWITCH, defaults={'active': True}) self.user = factories.UserFactory() self.condition = factories.EnterpriseCustomerConditionFactory() self.test_product = ProductFactory(stockrecords__price_excl_tax=10, categories=[]) self.course_run = CourseFactory(partner=self.partner) self.course_run.create_or_update_seat('verified', True, Decimal(100))
def setUp(self): super(EnterpriseCustomerConditionTests, self).setUp() self.user = UserFactory() self.condition = factories.EnterpriseCustomerConditionFactory() self.test_product = ProductFactory(stockrecords__price_excl_tax=10, categories=[]) self.course_run = CourseFactory(partner=self.partner) self.course_run.create_or_update_seat('verified', True, Decimal(100))
def setUp(self): super(EnterpriseCustomerConditionTests, self).setUp() self.user = UserFactory() self.condition = factories.EnterpriseCustomerConditionFactory() self.test_product = ProductFactory(stockrecords__price_excl_tax=10, categories=[]) self.course_run = CourseFactory(partner=self.partner) self.course_run.create_or_update_seat('verified', True, Decimal(100)) self.entitlement = create_or_update_course_entitlement( 'verified', 100, self.partner, 'edX-DemoX', 'edX Demo Entitlement' ) self.entitlement_stock_record = StockRecord.objects.filter(product=self.entitlement).first() self.entitlement_catalog = Catalog.objects.create(partner=self.partner) self.entitlement_catalog.stock_records.add(self.entitlement_stock_record)
def init_data(self, enterprise_customer, opportunity_id=None): """ Create database records to test against. """ self.create_coupon(enterprise_customer=enterprise_customer, sales_force_id=opportunity_id) factories.EnterpriseOfferFactory( condition=factories.EnterpriseCustomerConditionFactory( enterprise_customer_uuid=enterprise_customer), sales_force_id=opportunity_id) factories.ManualEnrollmentOrderOfferFactory( condition=factories.ManualEnrollmentOrderDiscountConditionFactory( enterprise_customer_uuid=enterprise_customer), sales_force_id=opportunity_id)
def test_name(self): """ The name should contain the EnterpriseCustomer's name. """ condition = factories.EnterpriseCustomerConditionFactory() expected = "Basket contains a seat from {}'s catalog".format(condition.enterprise_customer_name) self.assertEqual(condition.name, expected)
def setUp(self): super(BackfillOpportunityIdsCommandTests, self).setUp() # coupons and offers created for these enterprises are missing opportunity ids in database self.enterprise_without_opportunity_ids = { 'af4b351f-5f1c-4fc3-af41-48bb38fcb161': 'sf100', '8212a8d8-c6b1-4023-8754-4d687c43d72f': 'sf200', } # coupons and offers created for these enterprise have the opportunity id self.enterprise_with_opportunity_id = ('68c7b796-3d9c-4038-a870-3b5eb75c5d39', 'sf999') # create enterprise coupons, enterprise offers and manual orders without opportunity id for enterprise_customer, __ in self.enterprise_without_opportunity_ids.items(): self.init_data(enterprise_customer) # create an enterprise coupon, enterprise offer and manual order offer with opportunity id self.init_data( self.enterprise_with_opportunity_id[0], self.enterprise_with_opportunity_id[1], ) # multi contracts data setup for coupons and offers self.multi_contract_vouchers = [ ['0a434fa0-2edb-416a-ba24-0d504cc8f6d2', 1345, 'Voucher', 3000, 'OID400'], ['0a434fa0-2edb-416a-ba24-0d504cc8f6d2', 2876, 'Voucher', 3000, 'OID400'], ['0a434fa0-2edb-416a-ba24-0d504cc8f6d2', 9034, 'Voucher', 3000, 'OID450'], ['0a434fa0-2edb-416a-ba24-0d504cc8f6d2', 2223, 'Voucher', 3001, 'OID444'], ] created = [] for record in self.multi_contract_vouchers: if record[3] not in created: created.append(record[3]) coupon = self.create_coupon(enterprise_customer=record[0]) coupon.id = record[3] coupon.save() self.multi_contract_ent_offers = [ ['56b250c3-0050-47da-819c-e677fb8c03be', 4000, 'Site', '', 'OID500'], ['56b250c3-0050-47da-819c-e677fb8c03be', 4000, 'Site', '', 'OID500'], ['56b250c3-0050-47da-819c-e677fb8c03be', 4000, 'Site', '', 'OID550'], ['56b250c3-0050-47da-819c-e677fb8c03be', 4001, 'Site', '', 'OID555'], ] created = [] for record in self.multi_contract_ent_offers: if record[1] not in created: created.append(record[1]) factories.EnterpriseOfferFactory( id=record[1], condition=factories.EnterpriseCustomerConditionFactory( enterprise_customer_uuid=record[0] ) ) self.multi_contract_manual_offers = [ ['1204f563-ef3d-47cb-85c4-f67de61c5733', 6000, 'User', '', 'OID600'], ['1204f563-ef3d-47cb-85c4-f67de61c5733', 6000, 'User', '', 'OID600'], ['1204f563-ef3d-47cb-85c4-f67de61c5733', 6000, 'User', '', 'OID650'], ['1204f563-ef3d-47cb-85c4-f67de61c5733', 6001, 'User', '', 'OID666'], ] created = [] for record in self.multi_contract_manual_offers: if record[1] not in created: created.append(record[1]) factories.ManualEnrollmentOrderOfferFactory( id=record[1], condition=factories.ManualEnrollmentOrderDiscountConditionFactory( enterprise_customer_uuid=record[0] ) ) self.multi_contract_enterprises_with_opportunity_ids_only = [ ['1e57ef1f-c96b-47dd-9a7e-0bb24022ede5', '', '', '', 'OID700'], ['11e0a60d-0f79-4d96-a55b-4e126cb34a51', '', '', '', 'OID800'], ['9b951dd8-4bbd-4b5b-9186-c4bee1c96e1a', '', '', '', 'OID900'], ] for record in self.multi_contract_enterprises_with_opportunity_ids_only: self.init_data(record[0])