Пример #1
0
def test_nper_missing_pv():
    response = handlers.nper_handler({
        "rate": 0.005833333333333,
        "pmt": -150,
    }, None)

    assert 'error' in response
Пример #2
0
def test_nper_missing_pmt():
    response = handlers.nper_handler({
        "rate": 0.005833333333333,
        "pv": 8000
    }, None)

    assert 'error' in response
Пример #3
0
def test_nper_handler():
    # TODO test data types
    response = handlers.nper_handler(
        {
            "rate": 0.005833333333333,
            "pmt": -150,
            "pv": 8000
        }, None)
    assert 'result' in response
    assert round(response.get('result'), 5) == 64.07335

    # TODO Excel docs claim this isn't supported but Excel produces a value...
    response = handlers.nper_handler(
        {
            "rate": 0.005833333333333,
            "pv": 8000,
            "fv": -100
        }, None)
    assert 'result' in response
    assert round(response.get('result'), 5) == -753.39346

    response = handlers.nper_handler(
        {
            "rate": 0.005833333333333,
            "pmt": -150,
            "pv": 8000,
            "fv": -100
        }, None)
    assert 'result' in response
    assert round(response.get('result'), 5) == 63.40344

    response = handlers.nper_handler(
        {
            "rate": 0.005833333333333,
            "pmt": -150,
            "pv": 8000,
            "fv": -100,
            "type": 1
        }, None)
    assert 'result' in response
    assert round(response.get('result'), 5) == 62.95762
def test_nper_handler():
    # TODO test data types
    response = handlers.nper_handler(
        {
            "rate": 0.005833333333333,
            "pmt": -150,
            "pv": 8000
        }, None)
    assert 'result' in response
    assert response.get('result').tolist() == pytest.approx(64.07335)

    # TODO Excel docs claim this isn't supported but Excel produces a value...
    response = handlers.nper_handler(
        {
            "rate": 0.005833333333333,
            "pv": 8000,
            "fv": -100
        }, None)
    assert 'result' in response
    assert response.get('result').tolist() == pytest.approx(-753.39346)

    response = handlers.nper_handler(
        {
            "rate": 0.005833333333333,
            "pmt": -150,
            "pv": 8000,
            "fv": -100
        }, None)
    assert 'result' in response
    assert response.get('result').tolist() == pytest.approx(63.40344)

    response = handlers.nper_handler(
        {
            "rate": 0.005833333333333,
            "pmt": -150,
            "pv": 8000,
            "fv": -100,
            "type": 1
        }, None)
    assert 'result' in response
    assert response.get('result').tolist() == pytest.approx(62.95762)
Пример #5
0
def test_nper_missing_rate():
    response = handlers.nper_handler({"pmt": -150, "pv": 8000}, None)

    assert 'error' in response