From 3bc040b89c8f6bf83b516b90ccf913d290205a29 Mon Sep 17 00:00:00 2001 From: Iris Ho Date: Fri, 31 Jan 2025 20:03:01 -0800 Subject: [PATCH 1/5] Convert test.test_sessions_unified to async --- test/asynchronous/test_sessions_unified.py | 40 ++++++++++++++++++++++ test/test_sessions_unified.py | 9 ++++- tools/synchro.py | 1 + 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 test/asynchronous/test_sessions_unified.py diff --git a/test/asynchronous/test_sessions_unified.py b/test/asynchronous/test_sessions_unified.py new file mode 100644 index 0000000000..9b155847fd --- /dev/null +++ b/test/asynchronous/test_sessions_unified.py @@ -0,0 +1,40 @@ +# Copyright 2021-present MongoDB, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Test the Sessions unified spec tests.""" +from __future__ import annotations + +import os +import sys +from pathlib import Path + +sys.path[0:0] = [""] + +from test import unittest +from test.unified_format import generate_test_classes + +_IS_SYNC = False + +# Location of JSON test specifications. +if _IS_SYNC: + TEST_PATH = os.path.join(Path(__file__).resolve().parent, "sessions") +else: + TEST_PATH = os.path.join(Path(__file__).resolve().parent.parent, "sessions") + + +# Generate unified tests. +globals().update(generate_test_classes(TEST_PATH, module=__name__)) + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_sessions_unified.py b/test/test_sessions_unified.py index c51b4642e7..9b155847fd 100644 --- a/test/test_sessions_unified.py +++ b/test/test_sessions_unified.py @@ -17,14 +17,21 @@ import os import sys +from pathlib import Path sys.path[0:0] = [""] from test import unittest from test.unified_format import generate_test_classes +_IS_SYNC = False + # Location of JSON test specifications. -TEST_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "sessions") +if _IS_SYNC: + TEST_PATH = os.path.join(Path(__file__).resolve().parent, "sessions") +else: + TEST_PATH = os.path.join(Path(__file__).resolve().parent.parent, "sessions") + # Generate unified tests. globals().update(generate_test_classes(TEST_PATH, module=__name__)) diff --git a/tools/synchro.py b/tools/synchro.py index eb44ef4ac0..8019be6d98 100644 --- a/tools/synchro.py +++ b/tools/synchro.py @@ -225,6 +225,7 @@ def async_only_test(f: str) -> bool: "test_retryable_writes.py", "test_retryable_writes_unified.py", "test_session.py", + "test_session_unified.py", "test_transactions.py", "unified_format.py", ] From e733af689f1c15c08bdb24824f61edc2d37ce758 Mon Sep 17 00:00:00 2001 From: Iris <58442094+sleepyStick@users.noreply.github.com> Date: Mon, 3 Feb 2025 11:41:32 -0800 Subject: [PATCH 2/5] Update test/asynchronous/test_sessions_unified.py Co-authored-by: Noah Stapp --- test/asynchronous/test_sessions_unified.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/asynchronous/test_sessions_unified.py b/test/asynchronous/test_sessions_unified.py index 9b155847fd..b4cbac5704 100644 --- a/test/asynchronous/test_sessions_unified.py +++ b/test/asynchronous/test_sessions_unified.py @@ -22,7 +22,7 @@ sys.path[0:0] = [""] from test import unittest -from test.unified_format import generate_test_classes +from test.asynchronous.unified_format import generate_test_classes _IS_SYNC = False From 6cae58768024f051ea1232b1a64a247fba1fa4a8 Mon Sep 17 00:00:00 2001 From: Iris Ho Date: Mon, 3 Feb 2025 11:49:27 -0800 Subject: [PATCH 3/5] pre-commit --- test/test_sessions_unified.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_sessions_unified.py b/test/test_sessions_unified.py index 9b155847fd..8ed04cbe88 100644 --- a/test/test_sessions_unified.py +++ b/test/test_sessions_unified.py @@ -22,7 +22,7 @@ sys.path[0:0] = [""] from test import unittest -from test.unified_format import generate_test_classes +from test.synchronous.unified_format import generate_test_classes _IS_SYNC = False From 528bd3a608fe7b0a9f16b040c74b1877833a2bd4 Mon Sep 17 00:00:00 2001 From: Iris <58442094+sleepyStick@users.noreply.github.com> Date: Mon, 3 Feb 2025 13:39:27 -0800 Subject: [PATCH 4/5] Update tools/synchro.py Co-authored-by: Noah Stapp --- tools/synchro.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/synchro.py b/tools/synchro.py index e943468d1b..49fb7ea99c 100644 --- a/tools/synchro.py +++ b/tools/synchro.py @@ -226,7 +226,7 @@ def async_only_test(f: str) -> bool: "test_retryable_writes.py", "test_retryable_writes_unified.py", "test_session.py", - "test_session_unified.py", + "test_sessions_unified.py", "test_srv_polling.py", "test_transactions.py", "unified_format.py", From bd57fd83705a5c37d971d7e88970dadb7091d263 Mon Sep 17 00:00:00 2001 From: Iris Ho Date: Mon, 3 Feb 2025 13:40:45 -0800 Subject: [PATCH 5/5] run pre-commit --- test/test_sessions_unified.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_sessions_unified.py b/test/test_sessions_unified.py index 8ed04cbe88..3c80c70d38 100644 --- a/test/test_sessions_unified.py +++ b/test/test_sessions_unified.py @@ -22,9 +22,9 @@ sys.path[0:0] = [""] from test import unittest -from test.synchronous.unified_format import generate_test_classes +from test.unified_format import generate_test_classes -_IS_SYNC = False +_IS_SYNC = True # Location of JSON test specifications. if _IS_SYNC: