Commit c37181b9 by Vedran Karačić

Merge pull request #766 from edx/dynamic-coupon-fixes

Dynamic catalog coupon fixes.
parents 9fd6f149 af181c9b
......@@ -108,8 +108,8 @@ class CouponMixin(object):
catalog(Catalog): Catalog of courses for which the coupon applies
code(str): Custom coupon code
benefit_value(int): The voucher benefit value
catalog_query(str): course query string
course_seat_types(JSONField): List of seat types
catalog_query(str): Course query string
course_seat_types(str): A string of comma-separated list of seat types
Returns:
coupon (Coupon)
......
......@@ -21,19 +21,19 @@ class CouponUtilsTests(CouponMixin, CourseCatalogTestMixin, CatalogPreviewMockMi
def setUp(self):
super(CouponUtilsTests, self).setUp()
self.query = 'key:*'
self.seat_types = 'verified'
self.seat_type = 'verified'
self.course_id = 'course-v1:test+test+test'
def test_get_seat_from_query(self):
""" Verify right seat is returned. """
course, seat = self.create_course_and_seat(course_id=self.course_id)
self.mock_dynamic_catalog_course_runs_api(query=self.query, course_run=course)
response = get_seats_from_query(self.site, self.query, self.seat_types)
response = get_seats_from_query(self.site, self.query, self.seat_type)
self.assertEqual(seat, response[0])
def test_get_seat_from_query_no_product(self):
""" Verify an empty list is returned for no matched seats. """
course, __ = self.create_course_and_seat(seat_type='professional', course_id=self.course_id)
self.mock_dynamic_catalog_course_runs_api(query=self.query, course_run=course)
response = get_seats_from_query(self.site, self.query, self.seat_types)
response = get_seats_from_query(self.site, self.query, self.seat_type)
self.assertEqual(response, [])
......@@ -13,7 +13,7 @@ def get_seats_from_query(site, query, seat_types):
Arguments:
site (Site): current site
query (str): course catalog query
seat_types (JSON): JSON object of accepted seat types
seat_types (str): a string with comma-separated accepted seat type names
Returns:
List of seat products retrieved from the course catalog query.
......
......@@ -174,7 +174,7 @@ class CouponViewSet(EdxOrderPlacementMixin, viewsets.ModelViewSet):
- note (str)
- max_uses (int)
- catalog_query (str)
- course_seat_types (list of strings)
- course_seat_types (str)
Returns:
A coupon product object.
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('offer', '0003_auto_20160517_1247'),
]
operations = [
migrations.AlterField(
model_name='range',
name='course_seat_types',
field=models.CharField(max_length=255, null=True, blank=True),
),
]
......@@ -357,7 +357,7 @@ class UtilTests(CouponMixin, CourseCatalogTestMixin, LmsApiMockMixin, TestCase):
title='Query coupon',
quantity=1,
catalog_query='course:*',
course_seat_types={'verified': 1}
course_seat_types='verified'
)
query_coupon.history.all().update(history_user=self.user)
self.mock_course_api_response(course=self.course)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment