""" Tests for cloud_interest_rate_calculator """ # pylint: disable=no-self-use,missing-function-docstring,missing-class-docstring import pytest import mock from src import lambda_function class TestExampleFunction: @pytest.mark.parametrize("event", [{"value": "One Thousand"}, {"not_value": 1000}]) def test_handler_bad_input(self, event): with pytest.raises(Exception): assert lambda_function.handler(event, {}) @mock.patch("src.lambda_function.get_factors") def test_handler_unexpected_error(self, mock_calculate_interest): event = {"value": "10"} mock_calculate_interest.side_effect = Exception() with pytest.raises(Exception): assert lambda_function.handler(event, {}) def test_handler(self): event = {"value": "10"} response = lambda_function.handler(event, {}) assert response == "1,2,5,10" @pytest.mark.parametrize( "initial,expected", [ (1, {1}), (10, {1, 2, 5, 10}), (60, {1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60}), (64, {1, 2, 4, 8, 16, 32, 64}), ], ) def test_get_factors(self, initial, expected): response = lambda_function.get_factors(initial) assert response == expected @pytest.mark.parametrize( "initial,expected", [([], ""), ([1], "1"), ([2], "2"), ([1, 2, 3], "1,2,3"), ([1, 3, 2], "1,2,3"),], ) def test_stringify(self, initial, expected): response = lambda_function.stringify(initial) assert response == expected