示例#1
0
    def test_delete_an_inventory_with_inventory_id(self):
        """ Delete an inventory """
        inventory = Inventory(product_id=1, available=True)
        inventory.save()
        self.assertEqual(len(Inventory.all()), 1)

        # delete the inventory and make sure it isn't in the database
        inventory.delete()
        self.assertEqual(len(Inventory.all()), 0)
 def test_delete_nonexist(self):
     """ Test deleting a nonexist inventory"""
     inventory = Inventory(product_id=1,
                           quantity=100,
                           restock_level=50,
                           condition="new",
                           available=True)
     inventory.id = '1cak41-nonexist'
     try:
         inventory.delete()
     except KeyError:
         self.assertRaises(KeyError)
    def test_delete_an_inventory_with_id(self):
        """ Delete an inventory """
        inventory = Inventory(product_id=1,
                              quantity=100,
                              restock_level=50,
                              condition="new",
                              available=True)
        inventory.save()
        self.assertEqual(len(Inventory.all()), 1)

        # delete the inventory and make sure it isn't in the database
        inventory.delete()
        self.assertEqual(len(Inventory.all()), 0)