def test_get_offers_for_enterprise_offer_no_catalog(self):
     """ Verify that the course offers data is returned for an enterprise catalog voucher. """
     self.mock_access_token_response()
     enterprise_customer_id = str(uuid4())
     voucher = prepare_enterprise_voucher(
         benefit_value=10,
         enterprise_customer=enterprise_customer_id,
     )
     request = self.prepare_offers_listing_request(voucher.code)
     offers = VoucherViewSet().get_offers(request=request, voucher=voucher)['results']
     self.assertEqual(len(offers), 0)
Example #2
0
 def test_get_offers_for_enterprise_offer_switch_on(self):
     """ Verify that the course offers data is returned for an enterprise catalog voucher. """
     Switch.objects.update_or_create(
         name=ENTERPRISE_OFFERS_FOR_COUPONS_SWITCH,
         defaults={'active': True})
     self.mock_access_token_response()
     course, seat = self.create_course_and_seat()
     enterprise_customer_id = str(uuid4())
     enterprise_catalog_id = str(uuid4())
     self.mock_enterprise_catalog_course_endpoint(
         self.site_configuration.enterprise_api_url,
         enterprise_catalog_id,
         course_run=course)
     voucher = prepare_enterprise_voucher(
         benefit_value=10,
         enterprise_customer=enterprise_customer_id,
         enterprise_customer_catalog=enterprise_catalog_id)
     benefit = voucher.offers.first().benefit
     request = self.prepare_offers_listing_request(voucher.code)
     offers = VoucherViewSet().get_offers(request=request,
                                          voucher=voucher)['results']
     first_offer = offers[0]
     self.assertEqual(len(offers), 1)
     self.assertDictEqual(
         first_offer, {
             'benefit': {
                 'type': get_benefit_type(benefit),
                 'value': benefit.value
             },
             'contains_verified':
             True,
             'course_start_date':
             '2016-05-01T00:00:00Z',
             'id':
             course.id,
             'image_url':
             'path/to/the/course/image',
             'multiple_credit_providers':
             False,
             'organization':
             CourseKey.from_string(course.id).org,
             'credit_provider_price':
             None,
             'seat_type':
             course.type,
             'stockrecords':
             serializers.StockRecordSerializer(
                 seat.stockrecords.first()).data,
             'title':
             course.name,
             'voucher_end_date':
             voucher.end_datetime,
         })
Example #3
0
 def test_get_offers_for_enterprise_offer_switch_on_no_catalog(self):
     """ Verify that the course offers data is returned for an enterprise catalog voucher. """
     Switch.objects.update_or_create(
         name=ENTERPRISE_OFFERS_FOR_COUPONS_SWITCH,
         defaults={'active': True})
     self.mock_access_token_response()
     enterprise_customer_id = str(uuid4())
     voucher = prepare_enterprise_voucher(
         benefit_value=10,
         enterprise_customer=enterprise_customer_id,
     )
     request = self.prepare_offers_listing_request(voucher.code)
     offers = VoucherViewSet().get_offers(request=request,
                                          voucher=voucher)['results']
     self.assertEqual(len(offers), 0)