freelawproject / courtlistener

A fully-searchable and accessible archive of court data including growing repositories of opinions, oral arguments, judges, judicial financial records, and federal filings.
https://www.courtlistener.com
Other
550 stars 151 forks source link

test(api): Clear cache before counting number of queries #4695

Closed ERosendo closed 6 days ago

ERosendo commented 6 days ago

This PR addresses a flaky test identified in issue #4624. The test was failing because the number of database queries was lower than expected.

Django's caching mechanism can sometimes reduce the number of database queries, leading to unexpected results. To resolve this, we've implemented a solution suggested in Django tickets #11505 and #23746. By clearing the cache before counting the queries, we ensure accurate results and prevent the test from failing.

Since applying this fix, the test has been consistently passing.

Links:

mlissner commented 6 days ago

This one meant to still be a draft?

ERosendo commented 6 days ago

sorry @mlissner, I thought I'd marked the PR as ready for review

mlissner commented 6 days ago

Thank you. Fun stuff.