Skip to content

Commit 3f94b72

Browse files
committed
changed some fixtures to async
1 parent d4a4508 commit 3f94b72

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

tests/integration/synapseclient/models/async/test_schema_organization.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Any, Optional
44

55
import pytest
6+
import pytest_asyncio
67

78
from synapseclient import Synapse
89
from synapseclient.core.constants.concrete_types import CREATE_SCHEMA_REQUEST
@@ -25,7 +26,7 @@ def create_test_entity_name():
2526
return f"SYNPY.TEST.{random_string}"
2627

2728

28-
def org_exists(name: str, synapse_client: Optional[Synapse] = None) -> bool:
29+
async def org_exists(name: str, synapse_client: Optional[Synapse] = None) -> bool:
2930
"""
3031
Checks if any organizations exists with the given name
3132
@@ -73,25 +74,28 @@ def fixture_json_schema(module_organization: SchemaOrganization) -> JSONSchema:
7374
return js
7475

7576

76-
@pytest.fixture(name="organization", scope="function")
77-
def fixture_organization(syn: Synapse, request) -> SchemaOrganization:
77+
@pytest_asyncio.fixture(name="organization", loop_scope="function", scope="function")
78+
async def fixture_organization(syn: Synapse, request) -> SchemaOrganization:
7879
"""
7980
Returns a Synapse organization.
8081
"""
8182
name = create_test_entity_name()
8283
org = SchemaOrganization(name)
8384

84-
def delete_org():
85-
if org_exists(name, syn):
85+
async def delete_org():
86+
exists = await org_exists(name, syn)
87+
if exists:
8688
org.delete()
8789

8890
request.addfinalizer(delete_org)
8991

9092
return org
9193

9294

93-
@pytest.fixture(name="organization_with_schema", scope="function")
94-
def fixture_organization_with_schema(request) -> SchemaOrganization:
95+
@pytest_asyncio.fixture(
96+
name="organization_with_schema", loop_scope="function", scope="function"
97+
)
98+
async def fixture_organization_with_schema(request) -> SchemaOrganization:
9599
"""
96100
Returns a Synapse organization.
97101
As Cleanup it checks for JSON Schemas and deletes them"""
@@ -131,15 +135,17 @@ async def test_create_and_get(self, organization: SchemaOrganization) -> None:
131135
assert organization.created_by is None
132136
assert organization.created_on is None
133137
# AND it shouldn't exist in Synapse
134-
assert not org_exists(organization.name, synapse_client=self.syn)
138+
exists = await org_exists(organization.name, synapse_client=self.syn)
139+
assert not exists
135140
# WHEN I store the organization the metadata will be saved
136141
await organization.store_async(synapse_client=self.syn)
137142
assert organization.name is not None
138143
assert organization.id is not None
139144
assert organization.created_by is not None
140145
assert organization.created_on is not None
141146
# AND it should exist in Synapse
142-
assert org_exists(organization.name, synapse_client=self.syn)
147+
exists = await org_exists(organization.name, synapse_client=self.syn)
148+
assert exists
143149
# AND it should be getable by future instances with the same name
144150
org2 = SchemaOrganization(organization.name)
145151
await org2.get_async(synapse_client=self.syn)

0 commit comments

Comments
 (0)