def test_update(self): repository = MongoProductRepository(self.mongo_db) product = Product(name='Last of Us Part II', sku='AHJU-4968', cost=2.00, price=100.00, inventory_quantity=100) product_id = repository.add(product) repository.add( Product(name='Bloodborne', sku='AHJU-1458', cost=50.00, price=200.00, inventory_quantity=70)) product.define_id(product_id) product.update_infos(name='The Last of Us Part II', cost=10.00, price=220.00, inventory_quantity=150) repository.update(product) product = repository.get_by_id(product_id) self.assertEqual(product.id, product_id) self.assertEqual(product.name, 'The Last of Us Part II') self.assertEqual(product.cost, 10.00) self.assertEqual(product.price, 220.00) self.assertEqual(product.inventory_quantity, 150)
def test_should_update_infos(self): product = Product(id=1, name='Last of Us Part II', sku='AHJU-4968', cost=2.00, price=100.00, inventory_quantity=100) product.update_infos(name='The Last of Us Part II', cost=10.00, price=220.00, inventory_quantity=150) self.assertEqual(product.name, 'The Last of Us Part II') self.assertEqual(product.cost, 10.00) self.assertEqual(product.price, 220.00) self.assertEqual(product.inventory_quantity, 150)