class TestRoom(unittest.TestCase): def setUp(self) -> None: self.room = Room(name='Tsvetkovy', budget=250, members_count=4) def test_room_if_all_attributes_are_set_properly(self): self.assertEqual('Tsvetkovy', self.room.family_name) self.assertEqual(250, self.room.budget) self.assertEqual(4, self.room.members_count) def test_room_expenses_property_returns_the_expenses(self): result = self.room.expenses() self.assertEqual(0, result)
def test_expenses_set_when_eq_or_more_than_0(self): room = Room('test', 100, 2) room.expenses = 60 self.assertEqual(room.expenses, 60)
def test_expenses_raise_ex_when_less_than_0(self): with self.assertRaises(Exception) as ex: room = Room('test', 100, 2) room.expenses = -6 self.assertIsNotNone(ex.exception)
def test_expenses_propery_should_raise_value_error(self): room_one = Room('Ivanovi', 1500, 2) with self.assertRaises(ValueError) as exc: room_one.expenses = -10