Example #1
0
 def setUpClass(cls):
     super(BaseModelTestCase, cls).setUpClass()
     coupon = Coupon(code='sale',
                     valid_from=datetime.now(),
                     discount=10,
                     active=True,
                     valid_to=datetime.now() + timedelta(days=10))
     coupon.save()
     cls.order_sale = Order(first_name='Имя',
                            last_name='Фамилия',
                            email='*****@*****.**',
                            address='Улица, дом 1',
                            postal_code='123',
                            city='Город',
                            discount=10,
                            coupon=coupon)
     cls.order_sale.save()
     cls.order = Order(first_name='Имя',
                       last_name='Фамилия',
                       email='*****@*****.**',
                       address='Улица, дом 1',
                       postal_code='123',
                       city='Город')
     cls.order.save()
     category = Category(name='category_name', slug='category_slug')
     category.save()
     product_1 = Product(category=category,
                         name='product_1',
                         slug='slug_1',
                         price=5,
                         stock=1)
     product_2 = Product(category=category,
                         name='product_2',
                         slug='slug_2',
                         price=5,
                         stock=1)
     product_1.save()
     product_2.save()
     cls.order_item_1 = OrderItem(
         order=cls.order,
         product=product_1,
         price=product_1.price,
     )
     cls.order_item_2 = OrderItem(order=cls.order,
                                  product=product_2,
                                  price=product_2.price,
                                  quantity=5)
     cls.order_item_1.save()
     cls.order_item_2.save()
     cls.order_sale_item = OrderItem(order=cls.order_sale,
                                     product=product_2,
                                     price=product_2.price,
                                     quantity=5)
     cls.order_sale_item.save()
Example #2
0
 def test_save(self):
     coupon = Coupon(type='monetary', value=100)
     coupon.save()
     self.assertTrue(coupon.pk)