def test_removeProduct_shouldRaiseTypeErrorOnInvalidType(self): # Given sut = Shop() prodA = mock.Mock() prodA.mockVal = "Some product mock" # When / Then with self.assertRaises(TypeError): sut.removeProduct(prodA)
def test_removeProduct(self): # Given sut = Shop() prodA = mock.Mock(spec=Product) prodB = mock.Mock(spec=Product) prodC = mock.Mock(spec=Product) prodA.mockVal = "Some product mock A" prodB.mockVal = "Some product mock B" prodC.mockVal = "Some product mock C" expectedProducts = [prodA] sut.products = [prodA, prodB, prodC] # When sut.removeProduct(prodB) sut.removeProduct(prodC) # Then self.assertListEqual(expectedProducts, sut.products)