コード例 #1
0
ファイル: mixins.py プロジェクト: jphan169/ecommerce
    def coupon_product_class(self):
        defaults = {'requires_shipping': False, 'track_stock': False, 'name': COUPON_PRODUCT_CLASS_NAME}
        pc, created = ProductClass.objects.get_or_create(
            name=COUPON_PRODUCT_CLASS_NAME, slug=slugify(COUPON_PRODUCT_CLASS_NAME), defaults=defaults
        )

        if created:
            factories.ProductAttributeFactory(
                code='coupon_vouchers',
                name='Coupon vouchers',
                product_class=pc,
                type='entity'
            )
            factories.ProductAttributeFactory(
                code='note',
                name='Note',
                product_class=pc,
                type='text'
            )
            factories.ProductAttributeFactory(
                product_class=pc,
                name='Notification Email',
                code='notify_email',
                type='text'
            )

        return pc
コード例 #2
0
    def _create_product_class(self, class_name, slug, attributes):
        """ Helper method for creating product classes.

        Args:
            class_name (str): Name of the product class.
            slug (str): Slug of the product class.
            attributes (tuple): Tuple of tuples where each contains attribute name and type.

        Returns:
            ProductClass object.
        """

        defaults = {
            'requires_shipping': False,
            'track_stock': False,
            'name': class_name
        }
        pc, created = ProductClass.objects.get_or_create(slug=slug,
                                                         defaults=defaults)

        if created:
            for code, attr_type in attributes:
                factories.ProductAttributeFactory(code=code,
                                                  name=code,
                                                  product_class=pc,
                                                  type=attr_type)

        return pc
コード例 #3
0
    def seat_product_class(self):
        defaults = {
            'requires_shipping': False,
            'track_stock': False,
            'name': 'Seat'
        }
        pc, created = ProductClass.objects.get_or_create(slug='seat',
                                                         defaults=defaults)

        if created:
            attributes = (
                ('certificate_type', 'text'),
                ('course_key', 'text'),
                ('credit_provider', 'text'),
                ('id_verification_required', 'boolean'),
                ('credit_hours', 'integer'),
            )

            for code, attr_type in attributes:
                factories.ProductAttributeFactory(code=code,
                                                  name=code,
                                                  product_class=pc,
                                                  type=attr_type)

        return pc
コード例 #4
0
    def test_entity_attributes(self):
        unrelated_object = factories.PartnerFactory()
        attribute = factories.ProductAttributeFactory(type='entity')

        attribute_value = factories.ProductAttributeValueFactory(
            attribute=attribute, value_entity=unrelated_object)

        self.assertEqual(attribute_value.value, unrelated_object)
コード例 #5
0
ファイル: mixins.py プロジェクト: uzairr/ecommerce
    def coupon_product_class(self):
        defaults = {'requires_shipping': False, 'track_stock': False, 'name': 'Coupon'}
        pc, created = ProductClass.objects.get_or_create(name='Coupon', slug='coupon', defaults=defaults)

        if created:
            factories.ProductAttributeFactory(
                code='coupon_vouchers',
                name='Coupon vouchers',
                product_class=pc,
                type='entity'
            )
            factories.ProductAttributeFactory(
                code='note',
                name='Note',
                product_class=pc,
                type='text'
            )

        return pc
コード例 #6
0
    def setUp(self):
        self.option_group = factories.AttributeOptionGroupFactory()
        self.attr = factories.ProductAttributeFactory(
            type='multi_option',
            name='Sizes',
            code='sizes',
            option_group=self.option_group,
        )

        # Add some options to the group
        self.options = factories.AttributeOptionFactory.create_batch(
            3, group=self.option_group)
コード例 #7
0
ファイル: test_modules.py プロジェクト: pombreda/ecommerce
    def _create_attributes(self):
        """Create enrollment attributes and values for the Honor Seat in DemoX Course."""
        certificate_type = factories.ProductAttributeFactory(
            name='certificate_type', product_class=self.product_class, type="text"
        )
        certificate_type.save()

        course_key = factories.ProductAttributeFactory(
            name='course_key', product_class=self.product_class, type="text"
        )
        course_key.save()

        certificate_value = factories.ProductAttributeValueFactory(
            attribute=certificate_type, product=self.seat, value_text='honor'
        )
        certificate_value.save()

        key_value = factories.ProductAttributeValueFactory(
            attribute=course_key, product=self.seat, value_text='edX/DemoX/Demo_Course'
        )
        key_value.save()
コード例 #8
0
    def setUp(self):
        # Override all loggers, suppressing logging calls of severity CRITICAL and below
        logging.disable(logging.CRITICAL)

        user = User.objects.create_user(username='******',
                                        email='*****@*****.**',
                                        password='******')

        self.product_class = factories.ProductClassFactory(
            name='Seat', requires_shipping=False, track_stock=False)

        product_attribute = factories.ProductAttributeFactory(
            name='course_key',
            code='course_key',
            product_class=self.product_class,
            type='text')

        fried_chicken = factories.ProductFactory(
            structure='parent',
            title=u'𝑭𝒓𝒊𝒆𝒅 𝑪𝒉𝒊𝒄𝒌𝒆𝒏',
            product_class=self.product_class,
            stockrecords=None,
        )

        factories.ProductAttributeValueFactory(
            attribute=product_attribute,
            product=fried_chicken,
            value_text='pollos/chickenX/2015')

        pollos_hermanos = factories.ProductFactory(
            structure='child',
            parent=fried_chicken,
            title=u'𝕃𝕠𝕤 ℙ𝕠𝕝𝕝𝕠𝕤 ℍ𝕖𝕣𝕞𝕒𝕟𝕠𝕤',
            stockrecords__partner_sku=u'ṠÖṀЁṪḦЇṄĠ⸚ḊЁḶЇĊЇÖÜṠ',
            stockrecords__price_excl_tax=D('9.99'),
        )

        self.attribute_value = factories.ProductAttributeValueFactory(
            attribute=product_attribute,
            product=pollos_hermanos,
            value_text='pollos/hermanosX/2015')

        self.basket = factories.create_basket(empty=True)
        self.basket.add_product(pollos_hermanos, 1)

        self.order = factories.create_order(number=self.ORDER_NUMBER,
                                            basket=self.basket,
                                            user=user)
        # the processor will pass through a string representation of this
        self.order_total = unicode(self.order.total_excl_tax)

        # Remove logger override
        self.addCleanup(logging.disable, logging.NOTSET)
コード例 #9
0
 def setUp(self):
     self.attr = factories.ProductAttributeFactory(type="boolean")
コード例 #10
0
 def setUp(self):
     self.attr = factories.ProductAttributeFactory(type="file")
コード例 #11
0
 def setUp(self):
     self.attr = factories.ProductAttributeFactory(type="integer")