At least 2 tests in the recommendation/test/test_api.py suite have been failing intermittently and blocking merges. Almost every time for this patch: https://gerrit.wikimedia.org/r/c/research/recommendation-api/+/1143605
test_section_recommendations
@pytest.mark.anyio
async def test_section_recommendations(client: AsyncClient):
response = await client.get(
"/v1/translation/sections?source=en&target=es&seed=Apple&search_algorithm=morelike&count=12"
)
assert response.status_code == 200
results = response.json()
assert len(results) == 12
assert results[0].get("source_title")
assert results[0].get("target_title")
assert results[0].get("source_sections")
assert results[0].get("target_sections")
assert results[0].get("present")
> assert results[0].get("missing")
E AssertionError: assert {}
E + where {} = <built-in method get of dict object at 0x104ec0940>('missing')
E + where <built-in method get of dict object at 0x104ec0940> = {'collection': None, 'missing': {}, 'present': {'External links': 'Enlaces externos', 'References': 'Referencias', 'Uses': 'Usos'}, 'source_sections': ['Uses', 'References', 'External links'], ...}.getThe absence of the missing property would suggest an article for which no section is missing in the target language. Therefore returning an invalid section recommendation.
test_recommendations_mostpopular
@pytest.mark.anyio
async def test_recommendations_mostpopular(client: AsyncClient):
response = await client.get("/v1/translation?source=en&target=es&seed=Moon&search_algorithm=morelike")
assert response.status_code == 200
results = response.json()
assert len(results) > 0
assert results[0].get("title")
assert results[0].get("pageviews") == 0
> assert results[0].get("wikidata_id")
E AssertionError: assert None
E + where None = <built-in method get of dict object at 0x7f5eee546900>('wikidata_id')
E + where <built-in method get of dict object at 0x7f5eee546900> = {'collection': None, 'langlinks_count': 0, 'pageviews': 0, 'rank': 302.0, ...}.getAbsence of wikidata_id? Is it a problem for the CX workflow?