def test_get_calories_remained(self, init_limit, data_records, negative_calories_remained, positive_calories_remained, msg_err): result = homework.CaloriesCalculator(init_limit) assert hasattr(result, 'get_calories_remained'), (msg_err( 'add_method', 'get_calories_remained', 'CaloriesCalculator')) records, today, week = data_records for record in records: result.add_record(record) if today < init_limit: assert result.get_calories_remained( ) == positive_calories_remained(init_limit - today), (msg_err( 'wrong_method', 'get_calories_remained', 'CaloriesCalculator')) result.limit = today - 200 assert result.get_calories_remained( ) == negative_calories_remained, (msg_err('wrong_method', 'get_calories_remained', 'CaloriesCalculator')) else: assert result.get_calories_remained( ) == negative_calories_remained, (msg_err('wrong_method', 'get_calories_remained', 'CaloriesCalculator')) result.limit = today + 200 assert result.get_calories_remained( ) == positive_calories_remained(init_limit - today), (msg_err( 'wrong_method', 'get_calories_remained', 'CaloriesCalculator'))
def test_init(self, init_limit, msg_err): assert hasattr(homework, 'CaloriesCalculator'), \ msg_err('add_class', 'CaloriesCalculator', child=True, parent_name='Calculator') result = homework.CaloriesCalculator(init_limit) assert hasattr(result, 'limit'), msg_err('child_method', 'CaloriesCalculator', 'Calculator') assert result.limit == init_limit, msg_err('child_method', 'CaloriesCalculator', 'Calculator') assert not hasattr(result, 'USD_RATE'), msg_err('dont_create_attr', 'USD_RATE', 'CaloriesCalculator') assert not hasattr(result, 'EURO_RATE'), msg_err('dont_create_attr', 'EURO_RATE', 'CaloriesCalculator')