def test_typeahead_api_unit_only(rf, typeahead_test_objects, typeahead_view):
    unit = typeahead_test_objects["unit"]
    sauna = typeahead_test_objects["sauna"]

    # Test just the unit; the resource must not be there
    response = typeahead_view(request=rf.get("/", {"input": "testi", "types": "unit"}))
    assert_response_does_not_contain(response, '"id":"%s"' % sauna.id)
    assert_response_contains(response, '"id":"%s"' % unit.id)
def test_typeahead_api_bogus_type(rf, typeahead_view):
    # Test that bogus types are quietly skipped
    response = typeahead_view(request=rf.get("/", {
        "input": "testi",
        "types": "hello"
    }))
    assert_response_does_not_contain(
        response, '"id"')  # presence of an id means something was returned
def test_typeahead_api_unit_only(rf, typeahead_test_objects, typeahead_view):
    unit = typeahead_test_objects["unit"]
    sauna = typeahead_test_objects["sauna"]

    # Test just the unit; the resource must not be there
    response = typeahead_view(request=rf.get("/", {
        "input": "testi",
        "types": "unit"
    }))
    assert_response_does_not_contain(response, '"id":"%s"' % sauna.id)
    assert_response_contains(response, '"id":"%s"' % unit.id)
def test_typeahead_api_valid_query_with_no_results(rf, typeahead_view):
    # Test that bogus queries are skipped too
    response = typeahead_view(request=rf.get("/", {"input": get_random_string(32)}))
    assert_response_does_not_contain(response, '"id"')  # presence of an id means something was returned
def test_typeahead_api_bogus_query(rf, typeahead_view):
    # Test that bogus queries are skipped too
    response = typeahead_view(request=rf.get("/", {"input": "t k p"}))
    assert_response_does_not_contain(response, '"id"')  # presence of an id means something was returned
def test_typeahead_api_bogus_type(rf, typeahead_view):
    # Test that bogus types are quietly skipped
    response = typeahead_view(request=rf.get("/", {"input": "testi", "types": "hello"}))
    assert_response_does_not_contain(response, '"id"')  # presence of an id means something was returned
def test_typeahead_api_valid_query_with_no_results(rf, typeahead_view):
    # Test that bogus queries are skipped too
    response = typeahead_view(
        request=rf.get("/", {"input": get_random_string(32)}))
    assert_response_does_not_contain(
        response, '"id"')  # presence of an id means something was returned
def test_typeahead_api_bogus_query(rf, typeahead_view):
    # Test that bogus queries are skipped too
    response = typeahead_view(request=rf.get("/", {"input": "t k p"}))
    assert_response_does_not_contain(
        response, '"id"')  # presence of an id means something was returned