def test_find_or_404_found(self): """ Find or return 404 found """ inv_items = InventoryFactory.create_batch(3) for inv_item in inv_items: inv_item.create() inv_item = Inventory.find_or_404(inv_items[1].id) self.assertIsNot(inv_item, None) self.assertEqual(inv_item.id, inv_items[1].id) self.assertEqual(inv_item.name, inv_items[1].name) self.assertEqual(inv_item.quantity, inv_items[1].quantity) self.assertEqual(inv_item.sku, inv_items[1].sku)
def test_find_or_404_found(self): """ Find or return 404 found """ Inventory(product_id=1, quantity=100, restock_level=50, condition="new", available=False).save() used_inventory = Inventory(product_id=2, quantity=21, restock_level=20, condition="used", available=True) used_inventory.save() inventory = Inventory.find_or_404(used_inventory.inventory_id) self.assertNotEqual(inventory, None) self.assertEqual(inventory.product_id, 2) self.assertEqual(inventory.quantity, 21) self.assertEqual(inventory.restock_level, 20) self.assertEqual(inventory.condition, "used") self.assertEqual(inventory.available, True)