def test_tas_unparsable_no_main(client, monkeypatch, elasticsearch_award_index,
                                award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(
        client, {"require": [["011", "011-0990", "011-2000/2000-000"]]})

    assert resp.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY, "Failed to return 422 Response"
Пример #2
0
def test_sibling_filters_on_one_sibling(
    client, monkeypatch, elasticsearch_award_index, multiple_awards_with_sibling_tas
):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [_tas_path(SISTER_TAS[1])]})

    assert resp.json()["results"] == [_award2()]
Пример #3
0
def test_double_eclipsing_filters2(client, monkeypatch, elasticsearch_award_index, award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(
        client, {"require": [_fa_path(BASIC_TAS)], "exclude": [_agency_path(BASIC_TAS), _tas_path(BASIC_TAS)]}
    )

    assert resp.json()["results"] == []
def test_match_on_multiple_awards(client, monkeypatch, elasticsearch_award_index, multiple_awards_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [_tas_path(BASIC_TAS), _tas_path(1)]})

    assert resp.json()["results"].sort(key=lambda elem: elem["internal_id"]) == [_award1(), _award2()].sort(
        key=lambda elem: elem["internal_id"]
    )
def test_tas_filter_inappropriate_characters(client, monkeypatch,
                                             elasticsearch_award_index,
                                             award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [["011", "[abc]"]]})

    assert resp.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY, "Failed to return 422 Response"
def test_tas_filter_not_object_or_list(client, monkeypatch,
                                       elasticsearch_award_index,
                                       award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, "This shouldn't be a string")

    assert resp.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY, "Failed to return 422 Response"
Пример #7
0
def test_sibling_filters_on_both_siblings(
    client, monkeypatch, elasticsearch_award_index, multiple_awards_with_sibling_tas
):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [_tas_path(SISTER_TAS[0]), _tas_path(SISTER_TAS[1])]})

    assert resp.json()["results"].sort(key=lambda elem: elem["internal_id"]) == [_award1(), _award2()].sort(
        key=lambda elem: elem["internal_id"]
    )
def test_tas_filter_is_legacy(client, monkeypatch, elasticsearch_award_index,
                              award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, [{
        "main": TAS_DICTIONARIES[0]["main"],
        "aid": TAS_DICTIONARIES[0]["aid"]
    }])

    assert len(resp.json()["results"]) == 1
def test_non_match_unintuitive_tas_from_tas(
    client, monkeypatch, elasticsearch_award_index, tas_with_nonintuitive_agency
):
    # ensure that api CANNOT find a TAS from the agency in the TAS code's aid, because it's actually linked under a
    # different agency
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [_tas_path(BASIC_TAS)]})

    assert resp.json()["results"] == []
Пример #10
0
def test_sibling_eclipsing_filters(client, monkeypatch, elasticsearch_award_index, multiple_awards_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(
        client,
        {
            "require": [_agency_path(BASIC_TAS), _tas_path(ATA_TAS)],
            "exclude": [_agency_path(ATA_TAS), _tas_path(BASIC_TAS)],
        },
    )

    assert resp.json()["results"] == [_award2()]
Пример #11
0
def test_sibling_filters_with_fa_excluding_two_siblings(
    client, monkeypatch, elasticsearch_award_index, multiple_awards_with_sibling_tas
):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(
        client,
        {
            "require": [_fa_path(SISTER_TAS[0]), _tas_path(SISTER_TAS[0]), _tas_path(SISTER_TAS[1])],
            "exclude": [_tas_path(SISTER_TAS[0]), _tas_path(SISTER_TAS[2])],
        },
    )

    assert resp.json()["results"] == [_award2()]
Пример #12
0
def test_exclude_overrides_require(client, monkeypatch, elasticsearch_award_index, award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [_tas_path(BASIC_TAS)], "exclude": [_tas_path(BASIC_TAS)]})

    assert resp.json()["results"] == []
Пример #13
0
def test_tas_level_require_non_match(client, monkeypatch, elasticsearch_award_index, award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [_tas_path(ATA_TAS)]})

    assert resp.json()["results"] == []
def test_match_unintuitive_tas(client, monkeypatch, elasticsearch_award_index, tas_with_nonintuitive_agency):
    # ensure that api can find a TAS that is under an agency not implied by the tas code
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [[UNINTUITIVE_AGENCY, _fa(BASIC_TAS), _tas(BASIC_TAS)]]})

    assert resp.json()["results"] == [_award1()]
def test_match_from_bpoa_tas(client, monkeypatch, elasticsearch_award_index, award_with_bpoa_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [_tas_path(BPOA_TAS)]})

    assert resp.json()["results"] == [_award1()]
def test_non_match_from_tas(client, monkeypatch, elasticsearch_award_index, award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [_agency_path(BASIC_TAS) + [TAS_STRINGS[ATA_TAS]]]})

    assert resp.json()["results"] == []
Пример #17
0
def test_agency_level_exclude_match(client, monkeypatch, elasticsearch_award_index, award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"exclude": [_agency_path(ATA_TAS)]})

    assert resp.json()["results"] == [_award1()]
Пример #18
0
def test_double_require(client, monkeypatch, elasticsearch_award_index, award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [_fa_path(BASIC_TAS), _tas_path(BASIC_TAS)]})

    assert resp.json()["results"] == [_award1()]
Пример #19
0
def test_fa_level_exclude_non_match(client, monkeypatch, elasticsearch_award_index, award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"exclude": [_fa_path(BASIC_TAS)]})

    assert resp.json()["results"] == []
def test_non_match_search_multi_tas_award(client, monkeypatch, elasticsearch_award_index, award_with_multiple_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas(client, {"require": [_tas_path(BPOA_TAS)]})

    assert resp.json()["results"] == []