class FurnitureTests(TestCase): """Tests for the Furniture class.""" def setUp(self): self.furn = Furniture("A1", "Test", 2, 3, "Wood", "S") def test_init(self): """Test object instantiation.""" self.assertEqual(self.furn.product_code, "A1") self.assertEqual(self.furn.description, "Test") self.assertEqual(self.furn.market_price, 2) self.assertEqual(self.furn.rental_price, 3) self.assertEqual(self.furn.material, "Wood") self.assertEqual(self.furn.size, "S") def test_return_dict(self): """Test return_as_dict method.""" # expected dict to return furn_dict = { 'product_code': "A1", 'description': "Test", 'market_price': 2, 'rental_price': 3, 'material': "Wood", 'size': "S" } self.assertEqual(furn_dict, self.furn.return_as_dict())
class TestFurniture(TestCase): """ tests modules in furniture_class.py """ def setUp(self): self.product_code = 199021 self.description = 'na' self.market_price = 100 self.rental_price = 500 self.material = 'gold' self.size = 'm' self.check_furniture = Furniture(self.product_code, self.description, self.market_price, self.rental_price, self.material, self.size) def test_init(self): """ check initialization of variables """ self.assertEqual(self.check_furniture.product_code, self.product_code) self.assertEqual(self.check_furniture.description, self.description) self.assertEqual(self.check_furniture.market_price, self.market_price) self.assertEqual(self.check_furniture.rental_price, self.rental_price) self.assertEqual(self.check_furniture.material, self.material) self.assertEqual(self.check_furniture.size, self.size) def test_return_as_dict(self): """ check dictionary output """ dict_output = self.check_furniture.return_as_dict() self.assertEqual(dict_output['product_code'], self.product_code) self.assertEqual(dict_output['description'], self.description) self.assertEqual(dict_output['market_price'], self.market_price) self.assertEqual(dict_output['rental_price'], self.rental_price) self.assertEqual(dict_output['material'], self.material) self.assertEqual(dict_output['size'], self.size)