コード例 #1
0
def test_context():

    assert isinstance(
        ixbrlContext(
            **{
                "_id": "123456",
                "entity": None,
                "segments": None,
                "instant": "2011-01-01",
                "startdate": None,
                "enddate": None,
            }).instant, datetime.date)

    interval = ixbrlContext(
        **{
            "_id": "123456",
            "entity": None,
            "segments": None,
            "instant": None,
            "startdate": "2011-01-01",
            "enddate": "2011-12-31",
        })
    assert isinstance(interval.startdate, datetime.date)
    assert isinstance(interval.enddate, datetime.date)
    assert interval.startdate.year == 2011
    assert interval.enddate.month == 12
コード例 #2
0
def test_context_json():

    instant_context = ixbrlContext(
        **{
            "_id": "123456",
            "entity": None,
            "segments": None,
            "instant": "2011-01-01",
            "startdate": None,
            "enddate": None,
        }).to_json()
    assert instant_context["instant"] == "2011-01-01"
    assert instant_context["startdate"] is None

    interval = ixbrlContext(
        **{
            "_id": "123456",
            "entity": None,
            "segments": None,
            "instant": None,
            "startdate": "2011-01-01",
            "enddate": "2011-12-31",
        }).to_json()
    assert interval["startdate"] == "2011-01-01"
    assert interval["instant"] is None
コード例 #3
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)
コード例 #4
0
def test_context_segments():

    i = ixbrlContext(**{
        "_id": "123456",
        "entity": None,
        "segments": [{
            "tag": "1",
            "value": "2",
            "dimension": "3"
        }],
        "instant": None,
        "startdate": "2011-01-01",
        "enddate": "2011-12-31",
    })
    assert len(i.segments) == 1
    assert i.segments[0]["value"] == "2"
    assert "with segment" in str(i)
コード例 #5
0
def test_nonnumeric_json():

    a = {
        "context":
        ixbrlContext(
            **{
                "_id": "123456",
                "entity": None,
                "segments": None,
                "instant": "2011-01-01",
                "startdate": None,
                "enddate": None,
            }),
        "format_":
        "",
        "value":
        "",
    }

    x = ixbrlNonNumeric(name="value", **a).to_json()
    assert "context" in x