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)
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)
def test_overflow_shipping_cost_scenario_handled_correctly(self): basket = factories.BasketFactory() product_attribute_value = factories.ProductAttributeValueFactory( value_float=2.5) basket.add_product(product_attribute_value.product) self.standard.bands.create(upper_limit=1, charge=D('1.00')) self.standard.bands.create(upper_limit=2, charge=D('2.00')) charge = self.standard.calculate(basket) self.assertEqual(D('1.00') + D('2.00'), charge.excl_tax)
def test_simple_shipping_cost_scenario_handled_correctly(self): basket = factories.BasketFactory() product_attribute_value = factories.ProductAttributeValueFactory( value_float=2.5) basket.add_product(product_attribute_value.product) expected_charge = D('3.00') self.standard.bands.create(upper_limit=3, charge=expected_charge) charge = self.standard.calculate(basket) self.assertEqual(expected_charge, charge.excl_tax)
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()