コード例 #1
0
    def test_delete_a_shopcart(self):
        """Delete a shopcart and everything in it"""
        self.assertEqual(len(Shopcart.all()), 0)

        shopcart = Shopcart(user_id=12345)
        shopcart.create()

        self.assertEqual(shopcart.id, 1)
        self.assertEqual(len(Shopcart.all()), 1)

        self.assertEqual(len(ShopcartItem.all()), 0)

        shopcart_item = ShopcartItem(sid=1, sku=5000, name="soap", price=2.23, amount=3)
        shopcart_item.create()
        self.assertEqual(shopcart_item.id, 1)

        shopcart_item = ShopcartItem(sid=1, sku=5001, name="shampoo", price=3.77, amount=1)
        shopcart_item.create()
        self.assertEqual(shopcart_item.id, 2)

        self.assertEqual(len(ShopcartItem.all()), 2)

        shopcart.delete()
        self.assertEqual(len(ShopcartItem.all()), 0)
        self.assertEqual(len(Shopcart.all()), 0)
コード例 #2
0
ファイル: test_model.py プロジェクト: zzihan1203/shopcarts
 def test_delete(self):
 	""" Delete a item """
 	item = Shopcart(product_id = 3, customer_id = 4)
 	item.save()
 	self.assertEqual(len(Shopcart.all()) , 1)
 	# delete item and make sure it isn't in the database 
 	item.delete()
 	self.assertEqual(len(Shopcart.all()), 0)