def test_tas_filter_not_object_or_list(client, monkeypatch,
                                       elasticsearch_award_index,
                                       subaward_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(client, "This shouldn't be a string")

    assert resp.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY, "Failed to return 422 Response"
def test_tas_unparsable_no_main(client, monkeypatch, elasticsearch_award_index,
                                subaward_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(
        client, {"require": [["011", "011-0990", "011-2000/2000-000"]]})

    assert resp.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY, "Failed to return 422 Response"
Exemplo n.º 3
0
def test_match_on_multiple_awards(client, monkeypatch,
                                  elasticsearch_award_index,
                                  subaward_with_no_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(client, {"require": [_tas_path(BASIC_TAS)]})

    assert resp.json()["results"] == []
Exemplo n.º 4
0
def test_agency_level_exclude_match(client, monkeypatch,
                                    elasticsearch_award_index,
                                    subaward_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(client, {"exclude": [_agency_path(ATA_TAS)]})

    assert resp.json()["results"] == [_subaward1()]
Exemplo n.º 5
0
def test_match_from_agency(client, monkeypatch, elasticsearch_award_index,
                           subaward_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(client,
                                 {"require": [_agency_path(BASIC_TAS)]})

    assert resp.json()["results"] == [_subaward1()]
Exemplo n.º 6
0
def test_tas_level_require_non_match(client, monkeypatch,
                                     elasticsearch_award_index,
                                     subaward_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(client, {"require": [_tas_path(ATA_TAS)]})

    assert resp.json()["results"] == []
Exemplo n.º 7
0
def test_fa_level_exclude_non_match(client, monkeypatch,
                                    elasticsearch_award_index,
                                    subaward_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(client, {"exclude": [_fa_path(BASIC_TAS)]})

    assert resp.json()["results"] == []
Exemplo n.º 8
0
def test_sibling_filters_one_match(client, monkeypatch,
                                   elasticsearch_award_index,
                                   multiple_subawards_with_sibling_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(client,
                                 {"require": [_tas_path(SISTER_TAS[1])]})

    assert resp.json()["results"] == [_subaward2()]
def test_tas_filter_is_legacy(client, monkeypatch, elasticsearch_award_index,
                              subaward_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(client, [{
        "main": TAS_DICTIONARIES[0]["main"],
        "aid": TAS_DICTIONARIES[0]["aid"]
    }])

    assert len(resp.json()["results"]) == 1
Exemplo n.º 10
0
def test_non_match_from_unintuitive_tas_from_tas(
        client, monkeypatch, elasticsearch_award_index,
        subaward_with_unintuitive_agency):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    # 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
    resp = query_by_tas_subaward(client, {"require": [_tas_path(ATA_TAS)]})

    assert resp.json()["results"] == []
Exemplo n.º 11
0
def test_exclude_eclipsing_require(client, monkeypatch,
                                   elasticsearch_award_index,
                                   subaward_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(client, {
        "require": [_agency_path(BASIC_TAS)],
        "exclude": [_fa_path(BASIC_TAS)]
    })

    assert resp.json()["results"] == []
Exemplo n.º 12
0
def test_match_from_unintuitive_tas(client, monkeypatch,
                                    elasticsearch_award_index,
                                    subaward_with_unintuitive_agency):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(
        client,
        {"require": [[UNINTUITIVE_AGENCY,
                      _fa(BASIC_TAS),
                      _tas(BASIC_TAS)]]})

    assert resp.json()["results"] == [_subaward1()]
Exemplo n.º 13
0
def test_sibling_filters_two_matchs(client, monkeypatch,
                                    elasticsearch_award_index,
                                    multiple_subawards_with_sibling_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(
        client,
        {"require": [_tas_path(SISTER_TAS[1]),
                     _tas_path(SISTER_TAS[0])]})

    assert resp.json()["results"].sort(
        key=lambda elem: elem["internal_id"]) == [
            _subaward1(), _subaward2()
        ].sort(key=lambda elem: elem["internal_id"])
Exemplo n.º 14
0
def test_sibling_eclipsing_filters(client, monkeypatch,
                                   elasticsearch_award_index,
                                   multiple_subawards_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_tas_subaward(
        client,
        {
            "require": [_agency_path(BASIC_TAS),
                        _tas_path(ATA_TAS)],
            "exclude": [_agency_path(ATA_TAS),
                        _tas_path(BASIC_TAS)],
        },
    )

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