New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to algoliasearch 2.0 #28
Conversation
@@ -23,7 +23,7 @@ def join(self): | |||
self.tasks = [] | |||
|
|||
def set_extra_headers(self, headers): | |||
self.client.set_extra_headers(**headers) | |||
self.client._config.headers.update(headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the simplest way I found to not recreate the client each time.
Another solution would be to keep the application_id and api_key and recreate the client there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds fine.
@nunomaduro: What would you suggest to replace is_alive here? https://github.com/Kinto/kinto-algolia/pull/28/files#diff-b4035ea4376fe730a3020b7b36640a14R129 |
f8fc0bb
to
013331e
Compare
index.delete().wait() | ||
|
||
def isalive(self): | ||
self.client._transporter.read(Verb.GET, "1/isalive", {}, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's eventually how I did it, but I guess it would have been better to keep the isalive()
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Natim Sounds good at the moment, as this moment is not in our plans for the v2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you choose to remove it?
index.delete().wait() | ||
|
||
def isalive(self): | ||
self.client._transporter.read(Verb.GET, "1/isalive", {}, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Natim Sounds good at the moment, as this moment is not in our plans for the v2.
@@ -37,7 +37,7 @@ def test_present_in_heartbeat(self): | |||
|
|||
def test_returns_false_if_connection_fails(self): | |||
with mock.patch.object(self.app.app.registry.indexer, "client") as client: | |||
client.is_alive.side_effect = AlgoliaException | |||
client._transporter.read.side_effect = AlgoliaException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This side_effect
property doesn't exist. Is this test passing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is because client has been mocked on line 39 here.
@@ -23,7 +23,7 @@ def join(self): | |||
self.tasks = [] | |||
|
|||
def set_extra_headers(self, headers): | |||
self.client.set_extra_headers(**headers) | |||
self.client._config.headers.update(headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds fine.
Fixes #18
r? @nunomaduro