-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APP-168 Create new endpoint to get family data from vespa (#447)
* Get family data from vespa * Bump to 1.21.2 * Fix return type * Update families endpoint to use search * Update poetry.lock * Removed RDS dependency from endpoint * Fix tests * Bump to 1.23.2
- Loading branch information
1 parent
6aa72a2
commit b752115
Showing
8 changed files
with
160 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,7 +124,7 @@ lint: | |
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
- trufflehog@3.74.0 | ||
- trufflehog@3.73.0 | ||
- [email protected] | ||
|
||
actions: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "navigator_backend" | ||
version = "1.23.1" | ||
version = "1.23.2" | ||
description = "" | ||
authors = ["CPR-dev-team <[email protected]>"] | ||
packages = [{ include = "app" }, { include = "tests" }] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
51 changes: 51 additions & 0 deletions
51
tests/non_search/routers/documents/test_get_vespa_family.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import pytest | ||
from fastapi import status | ||
from fastapi.testclient import TestClient | ||
from sqlalchemy.orm import Session | ||
|
||
from app.service import search | ||
from tests.non_search.routers.documents.setup_doc_fam_lookup import ( | ||
_make_vespa_fam_lookup_request, | ||
) | ||
from tests.search.vespa.setup_search_tests import _populate_db_families | ||
|
||
|
||
@pytest.mark.search | ||
def test_families_slug_returns_not_found( | ||
data_db: Session, data_client: TestClient, valid_token, monkeypatch, test_vespa | ||
): | ||
_populate_db_families(data_db) | ||
monkeypatch.setattr(search, "_VESPA_CONNECTION", test_vespa) | ||
|
||
# Test by slug | ||
json_response = _make_vespa_fam_lookup_request( | ||
data_client, | ||
valid_token, | ||
"CCLW.family.9999999999.0", | ||
expected_status_code=status.HTTP_404_NOT_FOUND, | ||
) | ||
assert ( | ||
json_response["detail"] == "Nothing found for CCLW.family.9999999999.0 in Vespa" | ||
) | ||
|
||
|
||
@pytest.mark.search | ||
def test_families_slug_returns_correct_family( | ||
data_db: Session, data_client: TestClient, valid_token, monkeypatch, test_vespa | ||
): | ||
_populate_db_families(data_db) | ||
|
||
monkeypatch.setattr(search, "_VESPA_CONNECTION", test_vespa) | ||
|
||
# Test by slug | ||
body = _make_vespa_fam_lookup_request( | ||
data_client, | ||
valid_token, | ||
"CCLW.family.10246.0", | ||
) | ||
|
||
assert body["total_hits"] == 1 | ||
assert body["total_family_hits"] == 1 | ||
assert len(body["families"]) > 0 | ||
|
||
assert body["families"][0]["id"].split("::")[-1] == "CCLW.family.10246.0" |