Skip to content

Commit

Permalink
update requirements
Browse files Browse the repository at this point in the history
fix for company reconciliation
  • Loading branch information
drkane committed Feb 6, 2024
1 parent a957465 commit 5990160
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
11 changes: 10 additions & 1 deletion reconcile/api/reconcile_company.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from typing import Dict
from typing import Dict, List, Optional, Union

from charity_django.companies.models import CompanyTypeChoices
from django.http import Http404
Expand Down Expand Up @@ -79,6 +79,15 @@ def suggest_type(
]
}

def _get_orgtypes_from_str(
self, orgtype: Optional[Union[List[str], str]] = None
) -> List[str]:
if orgtype == "all":
return [t[0] for t in CompanyTypeChoices.choices]
if isinstance(orgtype, str):
return [orgtype]
return orgtype or []

def data_extension(self, request, body: DataExtensionQuery) -> Dict:
result = do_extend_query(
ids=body.ids,
Expand Down
42 changes: 42 additions & 0 deletions reconcile/tests/test_reconcile_company_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,48 @@ def test_company_reconcile(self):
registry=self.registry,
)

def test_company_reconcile_two(self):
self.mock_es.return_value.search.return_value = RECON_RESPONSE

for base_url, schema_version, schema, method in self.get_test_cases(
"reconciliation-result-batch.json", RECON_BASE_URLS, ["GET", "POST"]
):
with self.subTest(
base_url=base_url, schema_version=schema_version, method=method
):
response = self.do_request(
method,
base_url,
{
"queries": json.dumps(
{
"q0": {
"query": "Kane data",
"type": "/registered-company",
"type_strict": "should",
},
"q1": {
"query": "Tesco",
"type": "/registered-company",
"type_strict": "should",
},
}
),
},
)
self.assertEqual(response.status_code, 200)
data = response.json()
self.assertEqual(list(data.keys()), ["q0", "q1"])
self.assertEqual(len(data["q0"]["result"]), 10)
self.assertEqual(data["q0"]["result"][0]["id"], "12345670")

jsonschema.validate(
instance=data,
schema=schema,
cls=jsonschema.Draft7Validator,
registry=self.registry,
)

def test_reconcile_empty(self):
self.mock_es.return_value.search.return_value = EMPTY_RESPONSE

Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dj-database-url==1.2.0
# via
# -r requirements.in
# charity-django
django==4.2.2
django==4.2.9
# via
# -r requirements.in
# charity-django
Expand Down Expand Up @@ -142,7 +142,7 @@ inflect==7.0.0
# charity-django
iniconfig==2.0.0
# via pytest
jinja2==3.1.2
jinja2==3.1.3
# via -r requirements.in
jmespath==1.0.1
# via
Expand Down Expand Up @@ -176,7 +176,7 @@ packaging==23.2
# via pytest
parse==1.19.0
# via requests-html
pillow==9.4.0
pillow==10.2.0
# via django-markdownx
pluggy==1.4.0
# via pytest
Expand Down Expand Up @@ -306,7 +306,7 @@ ua-parser==0.16.1
# via -r requirements.in
url-normalize==1.4.3
# via requests-cache
urllib3==1.26.14
urllib3==1.26.18
# via
# -r requirements.in
# botocore
Expand Down

0 comments on commit 5990160

Please sign in to comment.