-
Notifications
You must be signed in to change notification settings - Fork 90
Add dumps methods #157
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
Merged
Merged
Add dumps methods #157
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c41f8cc
Add dumps support
eskombro 8860616
Add code samples
eskombro 0587b08
Lint
eskombro d2d83c8
Remove dump_status from config
eskombro 07ba174
Remove redundant assertions
eskombro 297b4de
Add MeiliSearchApiError test
eskombro 9678c97
Add wait_for_dump_creation
eskombro b45991a
Add wait_for_dump_creation for crate_dump test
eskombro f940fd5
Create and populate index before each test, clean after
eskombro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import time | ||
|
||
MASTER_KEY = 'masterKey' | ||
BASE_URL = 'http://127.0.0.1:7700' | ||
|
||
def clear_all_indexes(client): | ||
indexes = client.get_indexes() | ||
for index in indexes: | ||
client.get_index(index['uid']).delete() | ||
|
||
def wait_for_dump_creation(client, dump_uid): | ||
dump_status = client.get_dump_status(dump_uid) | ||
while dump_status['status'] == 'processing': | ||
time.sleep(0.1) | ||
dump_status = client.get_dump_status(dump_uid) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import json | ||
import pytest | ||
import meilisearch | ||
from meilisearch.tests import BASE_URL, MASTER_KEY, clear_all_indexes, wait_for_dump_creation | ||
from meilisearch.errors import MeiliSearchApiError | ||
|
||
class TestClientDumps: | ||
|
||
""" TESTS: Client dumps creation and status """ | ||
|
||
client = meilisearch.Client(BASE_URL, MASTER_KEY) | ||
index = None | ||
dataset_file = None | ||
dataset_json = None | ||
|
||
def setup_class(self): | ||
clear_all_indexes(self.client) | ||
self.dataset_file = open('./datasets/small_movies.json', 'r') | ||
self.dataset_json = json.loads(self.dataset_file.read()) | ||
self.dataset_file.close() | ||
|
||
def setup_method(self, method): | ||
"""Creates and populates an index before each test is run""" | ||
self.index = self.client.create_index(uid='indexUID-' + method.__name__) | ||
response = self.index.add_documents(self.dataset_json, primary_key='id') | ||
self.index.wait_for_pending_update(response['updateId']) | ||
|
||
def teardown_method(self, method): | ||
self.client.get_index('indexUID-' + method.__name__).delete() | ||
|
||
def teardown_class(self): | ||
"""Cleans all indexes in MEiliSearch when all the test are done""" | ||
clear_all_indexes(self.client) | ||
|
||
def test_dump_creation(self): | ||
"""Tests the creation of a MeiliSearch dump""" | ||
dump = self.client.create_dump() | ||
assert dump['uid'] is not None | ||
assert dump['status'] == 'processing' | ||
wait_for_dump_creation(self.client, dump['uid']) | ||
|
||
def test_dump_status_route(self): | ||
"""Tests the route for getting a MeiliSearch dump status""" | ||
dump = self.client.create_dump() | ||
assert dump['uid'] is not None | ||
assert dump['status'] == 'processing' | ||
dump_status = self.client.get_dump_status(dump['uid']) | ||
assert dump_status['uid'] is not None | ||
assert dump_status['status'] == 'processing' | ||
wait_for_dump_creation(self.client, dump['uid']) | ||
|
||
def test_dump_status_nonexistent_uid_raises_error(self): | ||
"""Tests the route for getting a nonexistent dump status""" | ||
with pytest.raises(MeiliSearchApiError): | ||
self.client.get_dump_status('uid_not_exists') |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.