algoliasearch-client-python icon indicating copy to clipboard operation
algoliasearch-client-python copied to clipboard

Simplify rule comparison with equality function

Open aseure opened this issue 5 years ago • 1 comments
trafficstars

In this commit https://github.com/algolia/algoliasearch-client-python/commit/108e270dd007734c814066abd08882be48fe767c#diff-448ff623544e049c870f5282201af825, an helper function was added to the tests to remove a _metadata extra key which is added by the engine to the rules returned by the API. Instead of doing this, we could write a custom equality method for the rules that would compare a rule with another one, without comparing the _metadata field. This way, we could get read of the extra helper from our test. More importantly, this would let the user compare two rules for equality is a simpler way. This suggestion is motivated by the fact that I had to rediscover this bug and re-implement it for the Django integration in this PR https://github.com/algolia/algoliasearch-django/pull/297. Same thing goes here: should we have a proper equality function, we could use it directly in our test assertions instead of rewriting a custom _metadata removal function.

WDYT?

aseure avatar Aug 14 '20 14:08 aseure

Thanks for the work @aseure, Yes it seems a really good idea. I'll implement the changes once I found time. 🚀

TomKlotzPro avatar Aug 14 '20 14:08 TomKlotzPro