def lambda_main(event, context) -> dict:
    change_amount = int(event['queryStringParameters']['change_amount'])
    response = {
        'statusCode': 200,
        'body': json.dumps(changer.change(change_amount))
    }
    return response
Example #2
0
def test_passing_1_returns_a_single_penny():
    assert changer.change(1) == [1]
Example #3
0
def test_returns_correct_combination_of_coins_in_complex_cases():
    assert changer.change(327) == [200, 100, 20, 5, 2]
    assert changer.change(159) == [100, 50, 5, 2, 2]
    assert changer.change(73) == [50, 20, 2, 1]
Example #4
0
def test_returns_correct_combination_of_three_coins_where_needed():
    assert changer.change(42) == [20, 20, 2]
    assert changer.change(23) == [20, 2, 1]
    assert changer.change(112) == [100, 10, 2]
Example #5
0
def test_returns_correct_combination_of_two_coins_where_needed():
    assert changer.change(3) == [2, 1]
    assert changer.change(6) == [5, 1]
    assert changer.change(25) == [20, 5]
Example #6
0
def test_passing_200_returns_2_pounds():
    assert changer.change(200) == [200]
Example #7
0
def test_passing_100_returns_1_pound():
    assert changer.change(100) == [100]
Example #8
0
def test_passing_0_returns_an_empty_list():
    assert changer.change(0) == []
Example #9
0
def test_passing_50_returns_50p():
    assert changer.change(50) == [50]
Example #10
0
def test_passing_20_returns_20p():
    assert changer.change(20) == [20]
Example #11
0
def test_passing_10_returns_10p():
    assert changer.change(10) == [10]
Example #12
0
def test_passing_5_returns_5p():
    assert changer.change(5) == [5]
Example #13
0
def test_passing_2_returns_2p():
    assert changer.change(2) == [2]
def cli_main() -> None:
    if __invalid_args():
        raise Exception('Please provide a numeric argument')
    else:
        print(changer.change(int(sys.argv[1])))