Skip to content

Commit 5526b8d

Browse files
committed
remove unnecessary imports and add style
1 parent b5839c3 commit 5526b8d

File tree

8 files changed

+168
-88
lines changed

8 files changed

+168
-88
lines changed

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

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
from synapseclient import Synapse
99
from synapseclient.core.exceptions import SynapseHTTPError
10-
from synapseclient.models import Evaluation, File, Project, Submission, SubmissionBundle, SubmissionStatus
10+
from synapseclient.models import (
11+
Evaluation,
12+
File,
13+
Project,
14+
Submission,
15+
SubmissionBundle,
16+
SubmissionStatus,
17+
)
1118

1219

1320
class TestSubmissionBundleRetrievalAsync:
@@ -52,7 +59,9 @@ async def test_file(
5259
syn: Synapse,
5360
schedule_for_cleanup: Callable[..., None],
5461
) -> File:
55-
file_content = f"Test file content for submission bundle async tests {uuid.uuid4()}"
62+
file_content = (
63+
f"Test file content for submission bundle async tests {uuid.uuid4()}"
64+
)
5665
with open("test_file_for_submission_bundle_async.txt", "w") as f:
5766
f.write(file_content)
5867

@@ -192,9 +201,15 @@ async def test_get_evaluation_submission_bundles_with_pagination_async(
192201

193202
# AND the bundle IDs should not overlap if we have enough submissions
194203
if len(bundles_page1) == 2 and len(bundles_page2) > 0:
195-
page1_ids = {bundle.submission.id for bundle in bundles_page1 if bundle.submission}
196-
page2_ids = {bundle.submission.id for bundle in bundles_page2 if bundle.submission}
197-
assert page1_ids.isdisjoint(page2_ids), "Pages should not have overlapping submissions"
204+
page1_ids = {
205+
bundle.submission.id for bundle in bundles_page1 if bundle.submission
206+
}
207+
page2_ids = {
208+
bundle.submission.id for bundle in bundles_page2 if bundle.submission
209+
}
210+
assert page1_ids.isdisjoint(
211+
page2_ids
212+
), "Pages should not have overlapping submissions"
198213

199214
async def test_get_evaluation_submission_bundles_invalid_evaluation_async(self):
200215
"""Test getting submission bundles for invalid evaluation ID using async methods."""
@@ -267,9 +282,15 @@ async def test_get_user_submission_bundles_with_pagination_async(
267282

268283
# AND the bundle IDs should not overlap if we have enough submissions
269284
if len(bundles_page1) == 2 and len(bundles_page2) > 0:
270-
page1_ids = {bundle.submission.id for bundle in bundles_page1 if bundle.submission}
271-
page2_ids = {bundle.submission.id for bundle in bundles_page2 if bundle.submission}
272-
assert page1_ids.isdisjoint(page2_ids), "Pages should not have overlapping submissions"
285+
page1_ids = {
286+
bundle.submission.id for bundle in bundles_page1 if bundle.submission
287+
}
288+
page2_ids = {
289+
bundle.submission.id for bundle in bundles_page2 if bundle.submission
290+
}
291+
assert page1_ids.isdisjoint(
292+
page2_ids
293+
), "Pages should not have overlapping submissions"
273294

274295

275296
class TestSubmissionBundleDataIntegrityAsync:
@@ -314,7 +335,9 @@ async def test_file(
314335
syn: Synapse,
315336
schedule_for_cleanup: Callable[..., None],
316337
) -> File:
317-
file_content = f"Test file content for data integrity async tests {uuid.uuid4()}"
338+
file_content = (
339+
f"Test file content for data integrity async tests {uuid.uuid4()}"
340+
)
318341
with open("test_file_for_data_integrity_async.txt", "w") as f:
319342
f.write(file_content)
320343

@@ -410,7 +433,9 @@ async def test_submission_bundle_status_updates_reflected_async(
410433
assert test_bundle.submission_status.status == "VALIDATED"
411434
assert test_bundle.submission_status.submission_annotations is not None
412435
assert "test_score" in test_bundle.submission_status.submission_annotations
413-
assert test_bundle.submission_status.submission_annotations["test_score"] == [95.5]
436+
assert test_bundle.submission_status.submission_annotations["test_score"] == [
437+
95.5
438+
]
414439

415440
# CLEANUP: Reset the status back to original
416441
submission_status.status = original_status

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

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ async def test_store_submission_status_with_status_change(
221221

222222
# WHEN I update the status
223223
test_submission_status.status = "VALIDATED"
224-
updated_status = await test_submission_status.store_async(synapse_client=self.syn)
224+
updated_status = await test_submission_status.store_async(
225+
synapse_client=self.syn
226+
)
225227

226228
# THEN the submission status should be updated
227229
assert updated_status.id == test_submission_status.id
@@ -239,7 +241,9 @@ async def test_store_submission_status_with_submission_annotations(
239241
"score": 85.5,
240242
"feedback": "Good work!",
241243
}
242-
updated_status = await test_submission_status.store_async(synapse_client=self.syn)
244+
updated_status = await test_submission_status.store_async(
245+
synapse_client=self.syn
246+
)
243247

244248
# THEN the submission annotations should be saved
245249
assert updated_status.submission_annotations is not None
@@ -256,7 +260,9 @@ async def test_store_submission_status_with_legacy_annotations(
256260
"internal_score": 92.3,
257261
"reviewer_notes": "Excellent submission",
258262
}
259-
updated_status = await test_submission_status.store_async(synapse_client=self.syn)
263+
updated_status = await test_submission_status.store_async(
264+
synapse_client=self.syn
265+
)
260266
assert updated_status.annotations is not None
261267

262268
converted_annotations = from_submission_status_annotations(
@@ -281,7 +287,9 @@ async def test_store_submission_status_with_combined_annotations(
281287
"internal_review": True,
282288
"notes": "Needs minor improvements",
283289
}
284-
updated_status = await test_submission_status.store_async(synapse_client=self.syn)
290+
updated_status = await test_submission_status.store_async(
291+
synapse_client=self.syn
292+
)
285293

286294
# THEN both types of annotations should be saved
287295
assert updated_status.submission_annotations is not None
@@ -307,7 +315,9 @@ async def test_store_submission_status_with_private_annotations_false(
307315
test_submission_status.private_status_annotations = False
308316

309317
# WHEN I store the submission status
310-
updated_status = await test_submission_status.store_async(synapse_client=self.syn)
318+
updated_status = await test_submission_status.store_async(
319+
synapse_client=self.syn
320+
)
311321

312322
# THEN they should be properly stored
313323
assert updated_status.annotations is not None
@@ -340,7 +350,9 @@ async def test_store_submission_status_with_private_annotations_true(
340350
)
341351

342352
# WHEN I store the submission status
343-
updated_status = await test_submission_status.store_async(synapse_client=self.syn)
353+
updated_status = await test_submission_status.store_async(
354+
synapse_client=self.syn
355+
)
344356

345357
# THEN they should be properly stored
346358
assert updated_status.annotations is not None
@@ -395,7 +407,9 @@ async def test_store_submission_status_change_tracking(
395407
assert test_submission_status.has_changed
396408

397409
# WHEN I store the changes
398-
updated_status = await test_submission_status.store_async(synapse_client=self.syn)
410+
updated_status = await test_submission_status.store_async(
411+
synapse_client=self.syn
412+
)
399413

400414
# THEN has_changed should be False again
401415
assert not updated_status.has_changed
@@ -431,7 +445,9 @@ async def test_has_changed_property_edge_cases(
431445
assert test_submission_status.has_changed
432446

433447
# WHEN I store and get a fresh copy
434-
updated_status = await test_submission_status.store_async(synapse_client=self.syn)
448+
updated_status = await test_submission_status.store_async(
449+
synapse_client=self.syn
450+
)
435451
fresh_status = await SubmissionStatus(id=updated_status.id).get_async(
436452
synapse_client=self.syn
437453
)
@@ -510,7 +526,7 @@ async def test_files(
510526
finally:
511527
# Clean up the temporary file
512528
os.unlink(temp_file_path)
513-
529+
514530
return files
515531

516532
@pytest.fixture(scope="function")
@@ -611,7 +627,9 @@ async def test_batch_update_submission_statuses(
611627
# GIVEN multiple submission statuses
612628
statuses = []
613629
for submission in test_submissions:
614-
status = await SubmissionStatus(id=submission.id).get_async(synapse_client=self.syn)
630+
status = await SubmissionStatus(id=submission.id).get_async(
631+
synapse_client=self.syn
632+
)
615633
# Update each status
616634
status.status = "VALIDATED"
617635
status.submission_annotations = {
@@ -717,33 +735,35 @@ async def test_submission(
717735
schedule_for_cleanup(created_submission.id)
718736
return created_submission
719737

720-
async def test_submission_cancellation_workflow(
721-
self, test_submission: Submission
722-
):
738+
async def test_submission_cancellation_workflow(self, test_submission: Submission):
723739
"""Test the complete submission cancellation workflow async."""
724740
# GIVEN a submission that exists
725741
submission_id = test_submission.id
726-
742+
727743
# WHEN I get the initial submission status
728-
initial_status = await SubmissionStatus(id=submission_id).get_async(synapse_client=self.syn)
729-
744+
initial_status = await SubmissionStatus(id=submission_id).get_async(
745+
synapse_client=self.syn
746+
)
747+
730748
# THEN initially it should not be cancellable or cancelled
731749
assert initial_status.can_cancel is False
732750
assert initial_status.cancel_requested is False
733-
751+
734752
# WHEN I update the submission status to allow cancellation
735753
initial_status.can_cancel = True
736754
updated_status = await initial_status.store_async(synapse_client=self.syn)
737-
755+
738756
# THEN the submission should be marked as cancellable
739757
assert updated_status.can_cancel is True
740758
assert updated_status.cancel_requested is False
741-
759+
742760
# WHEN I cancel the submission
743761
await test_submission.cancel_async()
744-
762+
745763
# THEN I should be able to retrieve the updated status showing cancellation was requested
746-
final_status = await SubmissionStatus(id=submission_id).get_async(synapse_client=self.syn)
764+
final_status = await SubmissionStatus(id=submission_id).get_async(
765+
synapse_client=self.syn
766+
)
747767
assert final_status.can_cancel is True
748768
assert final_status.cancel_requested is True
749769

tests/integration/synapseclient/models/synchronous/test_submission_bundle.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
from synapseclient import Synapse
99
from synapseclient.core.exceptions import SynapseHTTPError
10-
from synapseclient.models import Evaluation, File, Project, Submission, SubmissionBundle, SubmissionStatus
10+
from synapseclient.models import (
11+
Evaluation,
12+
File,
13+
Project,
14+
Submission,
15+
SubmissionBundle,
16+
SubmissionStatus,
17+
)
1118

1219

1320
class TestSubmissionBundleRetrieval:
@@ -22,9 +29,7 @@ def init(self, syn: Synapse, schedule_for_cleanup: Callable[..., None]) -> None:
2229
async def test_project(
2330
self, syn: Synapse, schedule_for_cleanup: Callable[..., None]
2431
) -> Project:
25-
project = Project(name=f"test_project_{uuid.uuid4()}").store(
26-
synapse_client=syn
27-
)
32+
project = Project(name=f"test_project_{uuid.uuid4()}").store(synapse_client=syn)
2833
schedule_for_cleanup(project.id)
2934
return project
3035

@@ -192,9 +197,15 @@ async def test_get_evaluation_submission_bundles_with_pagination(
192197

193198
# AND the bundle IDs should not overlap if we have enough submissions
194199
if len(bundles_page1) == 2 and len(bundles_page2) > 0:
195-
page1_ids = {bundle.submission.id for bundle in bundles_page1 if bundle.submission}
196-
page2_ids = {bundle.submission.id for bundle in bundles_page2 if bundle.submission}
197-
assert page1_ids.isdisjoint(page2_ids), "Pages should not have overlapping submissions"
200+
page1_ids = {
201+
bundle.submission.id for bundle in bundles_page1 if bundle.submission
202+
}
203+
page2_ids = {
204+
bundle.submission.id for bundle in bundles_page2 if bundle.submission
205+
}
206+
assert page1_ids.isdisjoint(
207+
page2_ids
208+
), "Pages should not have overlapping submissions"
198209

199210
async def test_get_evaluation_submission_bundles_invalid_evaluation(self):
200211
"""Test getting submission bundles for invalid evaluation ID."""
@@ -267,9 +278,15 @@ async def test_get_user_submission_bundles_with_pagination(
267278

268279
# AND the bundle IDs should not overlap if we have enough submissions
269280
if len(bundles_page1) == 2 and len(bundles_page2) > 0:
270-
page1_ids = {bundle.submission.id for bundle in bundles_page1 if bundle.submission}
271-
page2_ids = {bundle.submission.id for bundle in bundles_page2 if bundle.submission}
272-
assert page1_ids.isdisjoint(page2_ids), "Pages should not have overlapping submissions"
281+
page1_ids = {
282+
bundle.submission.id for bundle in bundles_page1 if bundle.submission
283+
}
284+
page2_ids = {
285+
bundle.submission.id for bundle in bundles_page2 if bundle.submission
286+
}
287+
assert page1_ids.isdisjoint(
288+
page2_ids
289+
), "Pages should not have overlapping submissions"
273290

274291

275292
class TestSubmissionBundleDataIntegrity:
@@ -284,9 +301,7 @@ def init(self, syn: Synapse, schedule_for_cleanup: Callable[..., None]) -> None:
284301
async def test_project(
285302
self, syn: Synapse, schedule_for_cleanup: Callable[..., None]
286303
) -> Project:
287-
project = Project(name=f"test_project_{uuid.uuid4()}").store(
288-
synapse_client=syn
289-
)
304+
project = Project(name=f"test_project_{uuid.uuid4()}").store(synapse_client=syn)
290305
schedule_for_cleanup(project.id)
291306
return project
292307

@@ -410,7 +425,9 @@ async def test_submission_bundle_status_updates_reflected(
410425
assert test_bundle.submission_status.status == "VALIDATED"
411426
assert test_bundle.submission_status.submission_annotations is not None
412427
assert "test_score" in test_bundle.submission_status.submission_annotations
413-
assert test_bundle.submission_status.submission_annotations["test_score"] == [95.5]
428+
assert test_bundle.submission_status.submission_annotations["test_score"] == [
429+
95.5
430+
]
414431

415432
# CLEANUP: Reset the status back to original
416433
submission_status.status = original_status
@@ -454,9 +471,7 @@ def init(self, syn: Synapse, schedule_for_cleanup: Callable[..., None]) -> None:
454471
async def test_project(
455472
self, syn: Synapse, schedule_for_cleanup: Callable[..., None]
456473
) -> Project:
457-
project = Project(name=f"test_project_{uuid.uuid4()}").store(
458-
synapse_client=syn
459-
)
474+
project = Project(name=f"test_project_{uuid.uuid4()}").store(synapse_client=syn)
460475
schedule_for_cleanup(project.id)
461476
return project
462477

tests/integration/synapseclient/models/synchronous/test_submission_status.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -713,31 +713,29 @@ async def test_submission(
713713
schedule_for_cleanup(created_submission.id)
714714
return created_submission
715715

716-
async def test_submission_cancellation_workflow(
717-
self, test_submission: Submission
718-
):
716+
async def test_submission_cancellation_workflow(self, test_submission: Submission):
719717
"""Test the complete submission cancellation workflow."""
720718
# GIVEN a submission that exists
721719
submission_id = test_submission.id
722-
720+
723721
# WHEN I get the initial submission status
724722
initial_status = SubmissionStatus(id=submission_id).get(synapse_client=self.syn)
725-
723+
726724
# THEN initially it should not be cancellable or cancelled
727725
assert initial_status.can_cancel is False
728726
assert initial_status.cancel_requested is False
729-
727+
730728
# WHEN I update the submission status to allow cancellation
731729
initial_status.can_cancel = True
732730
updated_status = initial_status.store(synapse_client=self.syn)
733-
731+
734732
# THEN the submission should be marked as cancellable
735733
assert updated_status.can_cancel is True
736734
assert updated_status.cancel_requested is False
737-
735+
738736
# WHEN I cancel the submission
739737
test_submission.cancel()
740-
738+
741739
# THEN I should be able to retrieve the updated status showing cancellation was requested
742740
final_status = SubmissionStatus(id=submission_id).get(synapse_client=self.syn)
743741
assert final_status.can_cancel is True

0 commit comments

Comments
 (0)