Пример #1
0
 def test_product_delete_cascades_to_specifications(self, database):
     product = Product(name='Product')
     child_1 = Specification(product=product)
     child_2 = Specification(product=product)
     product.create()
     assert len(product.specifications) is 2
     assert child_1.product_id is product.id
     assert child_2.product_id is product.id
     product.delete()
     assert not Specification.query.all()
     assert not Product.query.all()
Пример #2
0
 def test_product_delete_cascades_to_stock_products(self, database):
     stock = Stock(name='Stock')
     product = Product(name='Product')
     stock_product_1 = StockProduct(stock=stock,
                                    product=product,
                                    lot_number='Lot 1')
     stock_product_2 = StockProduct(stock=stock,
                                    product=product,
                                    lot_number='Lot 2')
     product.create()
     assert len(StockProduct.query.all()) is 2
     assert stock_product_1.product_id is product.id
     assert stock_product_2.product_id is product.id
     product.delete()
     assert not StockProduct.query.all()
     assert not Product.query.all()