Пример #1
0
 def test_constructor(self):
     """Test constructor. (10p)"""
     firstname = "Teemu"
     lastname = "Teekkari"
     money = 1000
     age = 30
     human_object = Human(firstname, lastname, money, age)
     returned_firstname, returned_lastname = human_object.return_name()
     returned_amount = human_object.return_money()
     returned_age = human_object.return_age()
     self.assertEqual(
         money, returned_amount,
         """Your costructor or method return_money() doesn't work correctly. 
     Intializing object with money={} and calling method return_money should return {} not {}"""
         .format(money, money, returned_amount))
     self.assertEqual((firstname, lastname), (
         returned_firstname, lastname
     ), """Your costructor or method return_name() doesn't work correctly. Method return_name() returned {}, {}.\n
     It should have been returned {}, {}""".format(returned_firstname,
                                                   returned_lastname,
                                                   firstname, lastname))
     self.assertEqual(
         age, returned_age,
         """Your costructor or method return_age() doesn't work correctly. Method return_age() returned {} not {}"""
         .format(age, returned_age))
Пример #2
0
 def test_pay_salary(self):
     """Test method pay_salary. (5p)"""
     money = 1000
     salary = 500
     human_object = Human("Teemu", "Teekkari", money, 30)
     human_object.pay_salary(salary)
     returned_amount = human_object.return_money()
     self.assertEqual(
         money + salary, returned_amount,
         """Your costructor doesn't work correctly. 
     Intializing object with money={} and calling method pay_salary({}) should return {} not {}"""
         .format(money, salary, money + salary, returned_amount))
Пример #3
0
 def test_buy_something(self):
     """Test method buy_something. (5p)"""
     money = 1000
     cost_of_something = 500
     human_object = Human("Teemu", "Teekkari", money, 30)
     human_object.buy_something(cost_of_something)
     returned_amount = human_object.return_money()
     self.assertEqual(
         money - cost_of_something, returned_amount,
         """Your costructor doesn't work correctly. 
     Intializing object with money={} and calling method buy_something({}) should return {} not {}"""
         .format(money, cost_of_something, money - cost_of_something,
                 returned_amount))