Exemplo n.º 1
0
    def test_make(self):
        """Test that the factory method correctly makes a product."""
        
        # Products instantiated by the factory method
        opod_f = AbstractProduct.make(ProductType.OPOD, self.VALID_OPOD)
        opad_f = AbstractProduct.make(ProductType.OPAD, self.VALID_OPAD)
        ophone_f = AbstractProduct.make(ProductType.OPHONE, self.VALID_OPHONE)
        owatch_f = AbstractProduct.make(ProductType.OWATCH, self.VALID_OWATCH)
        otv_f = AbstractProduct.make(ProductType.OTV, self.VALID_OTV)

        self.assertEqual(self.opod, opod_f)
        self.assertEqual(self.opad, opad_f)
        self.assertEqual(self.ophone, ophone_f)
        self.assertEqual(self.owatch, owatch_f)
        self.assertEqual(self.otv, otv_f)
Exemplo n.º 2
0
 def test_make_error(self):
     """Test that a product cannot be made with
     an invalid serial number or product type.
     """
     with self.assertRaises(ProductError):
         AbstractProduct.make(ProductType.OPOD, SerialNumber(0))
     with self.assertRaises(ProductError):
         AbstractProduct.make(ProductType.OPAD, SerialNumber(0))
     with self.assertRaises(ProductError):
         AbstractProduct.make(ProductType.OPHONE, SerialNumber(0))
     with self.assertRaises(ProductError):
         AbstractProduct.make(ProductType.OWATCH, SerialNumber(0))
     with self.assertRaises(ProductError):
         AbstractProduct.make(ProductType.OTV, SerialNumber(0))
     
     with self.assertRaises(AttributeError):
         AbstractProduct.make(ProductType.INVALID, SerialNumber(0))