Beispiel #1
0
def test_rate_handler():
    # TODO test data types
    response = handlers.rate_handler({
        "nper": 6,
        "pmt": -200,
        "pv": 1000
    }, None)
    assert 'result' in response
    assert round(response.get('result'), 6) == 0.054718

    response = handlers.rate_handler({"nper": 6, "pv": 1000, "fv": -100}, None)
    assert 'result' in response
    assert round(response.get('result'), 6) == -0.318708

    response = handlers.rate_handler(
        {
            "nper": 6,
            "pmt": -200,
            "pv": 1000,
            "fv": 0.10
        }, None)
    assert 'result' in response
    assert round(response.get('result'), 6) == 0.054695

    response = handlers.rate_handler(
        {
            "nper": 6,
            "pmt": -200,
            "pv": 1000,
            "fv": 0.10,
            "type": 1
        }, None)
    assert 'result' in response
    assert round(response.get('result'), 6) == 0.079278
Beispiel #2
0
def test_rate_missing_pv():
    response = handlers.rate_handler({
        "nper": 6,
        "pmt": -200,
        "fv": 0.10
    }, None)

    assert 'error' in response