algolia / algoliasearch-client-python

⚡️ A fully-featured and blazing-fast Python API client to interact with Algolia.
https://www.algolia.com/doc/api-client/getting-started/install/python/?language=python
MIT License
196 stars 66 forks source link

Simplify rule comparison with equality function #509

Closed aseure closed 1 month ago

aseure commented 4 years ago

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?

TomKlotzPro commented 4 years ago

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