def test_treasury_account_component_filter_appropriate_characters(
        client, monkeypatch, elasticsearch_award_index, award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    # "R" doesn't represent anything special here, it just makes sure the code is ok with any capital letter
    resp = query_by_treasury_account_components(client, [{"a": "R"}], None)

    assert resp.status_code == status.HTTP_200_OK, "Failed to return 422 Response"
Ejemplo n.º 2
0
def test_match_from_component_filter_only(client, monkeypatch,
                                          elasticsearch_award_index,
                                          award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_treasury_account_components(
        client, None, [component_dictionary(BASIC_TAS)])

    assert resp.json()["results"] == [_award1()]
Ejemplo n.º 3
0
def test_match_from_code_filter_only(client, monkeypatch,
                                     elasticsearch_award_index,
                                     award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_treasury_account_components(
        client, {"require": [_agency_path(BASIC_TAS)]}, None)

    assert resp.json()["results"] == [_award1()]
def test_treasury_account_component_filter_inappropriate_characters(
        client, monkeypatch, elasticsearch_award_index, award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_treasury_account_components(client, {
        "aid": "020",
        "main": "SELECT"
    }, None)

    assert resp.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY, "Failed to return 422 Response"
Ejemplo n.º 5
0
def test_non_match_from_component_both_filters(client, monkeypatch,
                                               elasticsearch_award_index,
                                               award_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_treasury_account_components(
        client, {"require": [_agency_path(ATA_TAS)]},
        [component_dictionary(ATA_TAS)])

    assert resp.json()["results"] == []
Ejemplo n.º 6
0
def test_different_matches_with_each_filter(client, monkeypatch,
                                            elasticsearch_award_index,
                                            multiple_awards_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_treasury_account_components(
        client, {"require": [_agency_path(BASIC_TAS)]},
        [component_dictionary(ATA_TAS)])

    assert resp.json()["results"].sort(
        key=lambda elem: elem["internal_id"]) == [
            _award1(), _award2()
        ].sort(key=lambda elem: elem["internal_id"])
Ejemplo n.º 7
0
def test_match_from_component_filter_despite_exclusion(
        client, monkeypatch, elasticsearch_award_index,
        multiple_awards_with_tas):
    _setup_es(client, monkeypatch, elasticsearch_award_index)
    resp = query_by_treasury_account_components(
        client,
        {
            "require": [_agency_path(BASIC_TAS)],
            "exclude": [_agency_path(BASIC_TAS)]
        },
        [component_dictionary(BASIC_TAS)],
    )

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