Exemple #1
0
    def test_update_coupon_category(self):
        category = factories.CategoryFactory()
        CouponViewSet().update_coupon_category(category_ids=[category.id],
                                               coupon=self.coupon)

        coupon_categories = ProductCategory.objects.filter(
            product=self.coupon).values_list('category', flat=True)
        self.assertIn(category.id, coupon_categories)
        self.assertEqual(len(coupon_categories), 1)
Exemple #2
0
    def test_update_category(self):
        category = factories.CategoryFactory()
        path = reverse('api:v2:coupons-detail', kwargs={'pk': self.coupon.id})
        data = {'id': self.coupon.id, 'category': {'name': category.name}}
        self.client.put(path, json.dumps(data), 'application/json')

        new_coupon = Product.objects.get(id=self.coupon.id)
        coupon_category = ProductCategory.objects.get(product=new_coupon)
        self.assertEqual(category.id, coupon_category.category.id)
Exemple #3
0
    def test_update_category(self):
        category = factories.CategoryFactory()
        path = reverse('api:v2:coupons-detail', kwargs={'pk': self.coupon.id})
        data = {'id': self.coupon.id, AC.KEYS.CATEGORY_IDS: [category.id]}
        self.client.put(path, json.dumps(data), 'application/json')

        new_coupon = Product.objects.get(id=self.coupon.id)
        coupon_categories = ProductCategory.objects.filter(
            product=new_coupon).values_list('category', flat=True)
        self.assertIn(category.id, coupon_categories)
        self.assertEqual(len(coupon_categories), 1)
Exemple #4
0
    def test_update_category(self):
        category = factories.CategoryFactory()
        path = reverse('api:v2:coupons-detail', kwargs={'pk': self.coupon.id})
        data = {
            'id': self.coupon.id,
            'category': {'name': category.name}
        }
        self.get_response('PUT', path, data)

        new_coupon = Product.objects.get(id=self.coupon.id)
        coupon_category = ProductCategory.objects.get(product=new_coupon)
        self.assertEqual(category.id, coupon_category.category.id)
Exemple #5
0
    def setUp(self):
        super(CourseCatalogTestMixin, self).setUp()

        # Force the creation of a seat ProductClass
        self.seat_product_class  # pylint: disable=pointless-statement
        self.enrollment_code_product_class  # pylint: disable=pointless-statement

        category_name = 'Seats'
        try:
            self.category = Category.objects.get(name=category_name)
        except Category.DoesNotExist:
            self.category = factories.CategoryFactory(name=category_name)
Exemple #6
0
    def setUp(self):
        super(DiscoveryTestMixin, self).setUp()

        # Force the creation of a seat ProductClass
        self.entitlement_product_class  # pylint: disable=pointless-statement
        self.seat_product_class  # pylint: disable=pointless-statement
        self.enrollment_code_product_class  # pylint: disable=pointless-statement

        for category_name in ['Course Entitlements', 'Seats']:
            try:
                Category.objects.get(name=category_name)
            except Category.DoesNotExist:
                factories.CategoryFactory(name=category_name)
        self.category = Category.objects.get(name='Seats')
Exemple #7
0
    def setUp(self):
        super(CouponMixin, self).setUp()
        self.category = factories.CategoryFactory(path='1000')

        # Force the creation of a coupon ProductClass
        self.coupon_product_class  # pylint: disable=pointless-statement