Skip to content

Commit 5cfffac

Browse files
Review feedback
- remove unused iter/aiter in unasync conversion table - improve contributing documentation wrt _async subdirectories - remove some code duplication in async test fixtures
1 parent 8b5fa41 commit 5cfffac

File tree

3 files changed

+16
-37
lines changed

3 files changed

+16
-37
lines changed

Diff for: CONTRIBUTING.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ The process for contributing to any of the Elasticsearch repositories is similar
2727

2828
2. Many classes included in this library are offered in two versions, for
2929
asynchronous and synchronous Python. When working with these classes, you only
30-
need to make changes to the asynchronous code, located in the *_async*
31-
subdirectory of the source tree. Once you've made your changes, run the
32-
following command to automatically generate the corresponding synchronous code:
30+
need to make changes to the asynchronous code, located in *_async*
31+
subdirectories in the source and tests trees. Once you've made your changes,
32+
run the following command to automatically generate the corresponding
33+
synchronous code:
3334

3435
.. code:: bash
3536

Diff for: tests/conftest.py

+12-32
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,8 @@ def write_client(client):
182182

183183

184184
@pytest_asyncio.fixture
185-
async def async_write_client(async_client):
185+
async def async_write_client(write_client, async_client):
186186
yield async_client
187-
for index_name in await async_client.indices.get(
188-
index="test-*", expand_wildcards="all"
189-
):
190-
await async_client.indices.delete(index=index_name)
191-
await async_client.options(ignore_status=404).indices.delete_template(
192-
name="test-template"
193-
)
194187

195188

196189
@fixture
@@ -443,18 +436,16 @@ def aggs_data():
443436
}
444437

445438

446-
@fixture
447-
def pull_request(write_client):
448-
sync_document.PullRequest.init()
449-
pr = sync_document.PullRequest(
439+
def make_pr(pr_module):
440+
return pr_module.PullRequest(
450441
_id=42,
451442
comments=[
452-
sync_document.Comment(
443+
pr_module.Comment(
453444
content="Hello World!",
454-
author=sync_document.User(name="honzakral"),
445+
author=pr_module.User(name="honzakral"),
455446
created_at=datetime(2018, 1, 9, 10, 17, 3, 21184),
456447
history=[
457-
sync_document.History(
448+
pr_module.History(
458449
timestamp=datetime(2012, 1, 1),
459450
diff="-Ahoj Svete!\n+Hello World!",
460451
)
@@ -463,30 +454,19 @@ def pull_request(write_client):
463454
],
464455
created_at=datetime(2018, 1, 9, 9, 17, 3, 21184),
465456
)
457+
458+
@fixture
459+
def pull_request(write_client):
460+
sync_document.PullRequest.init()
461+
pr = make_pr(sync_document)
466462
pr.save(refresh=True)
467463
return pr
468464

469465

470466
@pytest_asyncio.fixture
471467
async def async_pull_request(async_write_client):
472468
await async_document.PullRequest.init()
473-
pr = async_document.PullRequest(
474-
_id=42,
475-
comments=[
476-
async_document.Comment(
477-
content="Hello World!",
478-
author=async_document.User(name="honzakral"),
479-
created_at=datetime(2018, 1, 9, 10, 17, 3, 21184),
480-
history=[
481-
async_document.History(
482-
timestamp=datetime(2012, 1, 1),
483-
diff="-Ahoj Svete!\n+Hello World!",
484-
)
485-
],
486-
),
487-
],
488-
created_at=datetime(2018, 1, 9, 9, 17, 3, 21184),
489-
)
469+
pr = make_pr(async_document)
490470
await pr.save(refresh=True)
491471
return pr
492472

Diff for: utils/run-unasync.py

-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ def main(check=False):
3535
# Unasync all the generated async code
3636
additional_replacements = {
3737
"_async": "_sync",
38-
"aiter": "iter",
39-
"anext": "next",
4038
"AsyncElasticsearch": "Elasticsearch",
4139
"AsyncSearch": "Search",
4240
"AsyncMultiSearch": "MultiSearch",

0 commit comments

Comments
 (0)