# Path: habitat/views/parser.py
# def unparsed_filter(doc, req):


from ...views import parser
from copy import deepcopy



doc = {
    "type": "payload_telemetry",
    "data": {
        "_parsed": "tset tset"
    }
}

def test_unparsed_filter():
    fil = parser.unparsed_filter
    
    wrongtype = deepcopy(doc)
    wrongtype["type"] = "flight"
    assert not fil(wrongtype, {})

    parsed = deepcopy(doc)
    assert not fil(parsed, {})

    nodata = deepcopy(doc)
    del nodata['data']
    assert not fil(nodata, {})

    ok = deepcopy(doc)
    del ok['data']['_parsed']
    assert fil(ok, {})

def test_issue_241():
    # this should not produce an exception

# Path: habitat/views/parser.py
# def unparsed_filter(doc, req):


# Path: habitat/tests/test_views/test_parser.py
from ...views import parser
from copy import deepcopy




doc = {
    "type": "payload_telemetry",
    "data": {
        "_parsed": "tset tset"
    }
}

def test_unparsed_filter():
    fil = parser.unparsed_filter
    
    wrongtype = deepcopy(doc)
    wrongtype["type"] = "flight"
    assert not fil(wrongtype, {})

    parsed = deepcopy(doc)
    assert not fil(parsed, {})

    nodata = deepcopy(doc)
    del nodata['data']
    assert not fil(nodata, {})

    ok = deepcopy(doc)
    del ok['data']['_parsed']
    assert fil(ok, {})

def test_issue_241():
    # this should not produce an exception

    parser.unparsed_filter({"_deleted": True}, {})