Exemplo n.º 1
0
def test_entity_values_index_error():
    body = "12th december"
    entity = BaseEntity(
        range={"from": 0, "to": len(body)},
        body=body,
        dim="default",
        type="basic",
        values=[],
    )
    with pytest.raises(IndexError):
        entity.get_value()
Exemplo n.º 2
0
def test_entity_values_key_error():
    body = "12th december"
    entity = BaseEntity(
        range={
            "from": 0,
            "to": len(body)
        },
        body=body,
        dim="default",
        entity_type="basic",
        values=[{
            "key": "value"
        }],
    )
    with pytest.raises(KeyError):
        entity.get_value()
Exemplo n.º 3
0
def test_entity_parser():
    body = "12th december"
    entity = BaseEntity(
        range={"from": 0, "to": len(body)},
        body=body,
        dim="default",
        type="basic",
        values=[{"value": 0}],
    )
    entity.add_parser(mock_plugin)

    assert entity.parsers == ["mock_plugin"], "parser was not added"
    assert entity.get_value() == 0, "value incorrect"
Exemplo n.º 4
0
def test_base_entity_value_setter():
    body = "12th december"
    entity = BaseEntity(
        range={
            "from": 0,
            "to": len(body)
        },
        body=body,
        entity_type="basic",
        dim="default",
        values=[],
    )

    # Had this not been a deep copy, it would have matched.
    assert entity.get_value({"value": 5}) == 5, "Should be same"