Exemplo n.º 1
0
def test_numeric_to_json():

    assert (ixbrlNumeric({
        "context":
        ixbrlContext(
            **{
                "_id": "123456",
                "entity": None,
                "segments": None,
                "instant": "2011-01-01",
                "startdate": None,
                "enddate": None,
            }),
        "text":
        "1234",
    }).to_json()["value"] == 1234)
    assert (ixbrlNumeric({
        "context":
        ixbrlContext(
            **{
                "_id": "123456",
                "entity": None,
                "segments": None,
                "instant": "2011-01-01",
                "startdate": None,
                "enddate": None,
            }),
        "value":
        "1234",
    }).to_json()["value"] == 1234)
Exemplo n.º 2
0
def test_format_numwordsen():

    assert ixbrlNumeric({
        "text": "one thousand two hundred and thirty four",
        "format": "numwordsen"
    }).value == 1234
    assert ixbrlNumeric({"text": "eight", "format": "numwordsen"}).value == 8
    assert ixbrlNumeric({
        "text": "one thousand two hundred and thirty four point four five",
        "format": "numwordsen"
    }).value == 1234.45
Exemplo n.º 3
0
def test_numeric_scale_sign():

    assert ixbrlNumeric({
        "value": "1,234",
        "scale": "3",
        "sign": "-"
    }).value == -1234000
    assert ixbrlNumeric({
        "text": "1,234",
        "scale": "3",
        "sign": "-"
    }).value == -1234000
Exemplo n.º 4
0
def test_format_numdotdecimal():

    assert ixbrlNumeric({
        "text": "1234.12",
        "format": "numdotdecimal"
    }).value == 1234.12
    assert ixbrlNumeric({
        "text": "1234",
        "format": "numdotdecimal"
    }).value == 1234
    assert ixbrlNumeric({
        "text": "1234.34",
        "format": "numcommadot"
    }).value == 1234.34
    assert ixbrlNumeric({
        "text": "1234.45",
        "format": "numspacedot"
    }).value == 1234.45
    assert ixbrlNumeric({
        "text": "1,234.45",
        "format": "numspacedot"
    }).value == 1234.45
    assert ixbrlNumeric({
        "text": "1234.12",
        "format": "num-dot-decimal"
    }).value == 1234.12
Exemplo n.º 5
0
def test_format_numcomma():

    assert ixbrlNumeric({
        "text": "1234,12",
        "format": "numcomma"
    }).value == 1234.12
    assert ixbrlNumeric({"text": "1234", "format": "numcomma"}).value == 1234
    assert ixbrlNumeric({
        "text": "1234,34",
        "format": "numcomma"
    }).value == 1234.34
    assert ixbrlNumeric({
        "text": "1234,45",
        "format": "numcomma"
    }).value == 1234.45
    assert ixbrlNumeric({
        "text": "1.234,45",
        "format": "numcomma"
    }).value == 1234.45
    assert ixbrlNumeric({
        "text": "1234,12",
        "format": "numcomma"
    }).value == 1234.12
Exemplo n.º 6
0
def test_numeric_scale():

    assert ixbrlNumeric({"value": "1,234", "scale": "0"}).value == 1234
    assert ixbrlNumeric({"value": "1,234", "scale": "1"}).value == 12340
    assert ixbrlNumeric({"text": "1,234", "scale": "2"}).value == 123400
Exemplo n.º 7
0
def test_numeric_blank():

    assert ixbrlNumeric({"value": "-"}).value == 0
    assert ixbrlNumeric({"text": "-"}).value == 0
Exemplo n.º 8
0
def test_numeric_sign():

    assert ixbrlNumeric({"text": "1,234", "sign": "-"}).value == -1234
    assert ixbrlNumeric({"value": "1,234", "sign": "-"}).value == -1234
    assert ixbrlNumeric({"value": "1,234", "sign": ""}).value == 1234
Exemplo n.º 9
0
def test_numeric_comma_replace():

    assert ixbrlNumeric({"text": "1,234"}).value == 1234
    assert ixbrlNumeric({"value": "1,234"}).value == 1234
Exemplo n.º 10
0
def test_numeric_value():

    assert ixbrlNumeric({"text": "1234"}).value == 1234
    assert ixbrlNumeric({"value": "1234"}).value == 1234
Exemplo n.º 11
0
def test_format_zerodash():

    assert ixbrlNumeric({"text": "-", "format": "zerodash"}).value == 0
    assert ixbrlNumeric({"text": "-", "format": "numdash"}).value == 0
    assert ixbrlNumeric({"text": "-", "format": "numdotdecimal"}).value == 0
Exemplo n.º 12
0
def test_numeric_inf_format():

    assert ixbrlNumeric({"text": "1234", "decimals": "INF"}).value == 1234
Exemplo n.º 13
0
def test_format_nocontent():

    assert ixbrlNumeric({"text": "-", "format": "nocontent"}).value == 0
Exemplo n.º 14
0
def test_numeric_already_float():

    assert ixbrlNumeric({"value": 1234}).value == 1234
    assert ixbrlNumeric({"value": 1234.0}).value == 1234
Exemplo n.º 15
0
def test_numeric_value_error():

    with pytest.raises(ValueError):
        ixbrlNumeric({"text": "1234blahblab"})
    with pytest.raises(ValueError):
        ixbrlNumeric({"value": "1234blahblah"})