@@ -68,6 +68,23 @@ def test_values_monthly(self):
6868 assert self .infl_usd .values_monthly [- 1 ] == approx (- 0.0059 , abs = 1e-4 )
6969 assert self .infl_rub .values_monthly [- 1 ] == approx (0.0276 , abs = 1e-4 )
7070
71+ error_case_ids = ["invalid_date_format" , "nonexistent_date" , "invalid_value_type" ]
72+
73+ @pytest .mark .parametrize ("date, value" ,
74+ [("2022-06" , 100.0 ), ("2025-01" , 200.0 ), (pd .Timestamp .now ().strftime ('%Y-%m' ), 150.0 ),
75+ ("2024-02" , 300.0 )])
76+ def test_set_values_monthly_happy_path (self , date , value ): # Arrange instance = MyClass()
77+ self .infl_rub .set_values_monthly (date , value )
78+ assert self .infl_rub .values_monthly [pd .Period (date , freq = 'M' )] == value
79+
80+ @pytest .mark .parametrize ("date, value, expected_exception" ,
81+ [("12,2023" , 100.0 , ValueError ), ("2023-13" , 100.0 , ValueError ),
82+ ("2023-12" , "one hundred" , TypeError )],
83+ ids = error_case_ids )
84+ def test_set_values_monthly_error_cases (self , date , value , expected_exception ):
85+ with pytest .raises (expected_exception ):
86+ self .infl_rub .set_values_monthly (date , value )
87+
7188 def test_describe (self ):
7289 description = self .infl_rub .describe (years = [5 ])
7390 assert list (description .columns ) == [
0 commit comments