From 1996ca0d04f708667cef7faec305713644e2eb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Besson?= Date: Thu, 26 Oct 2023 16:24:48 +0100 Subject: [PATCH 1/5] Add Ice wheel packages for 3.11 --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 99a9e52..40bc674 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ deps = https://github.com/ome/zeroc-ice-py-github-ci/releases/download/0.2.0/zeroc_ice-3.6.5-cp38-cp38-linux_x86_64.whl; platform_system=="Linux" and python_version=="3.8" https://github.com/ome/zeroc-ice-py-github-ci/releases/download/0.2.0/zeroc_ice-3.6.5-cp39-cp39-linux_x86_64.whl; platform_system=="Linux" and python_version=="3.9" https://github.com/ome/zeroc-ice-py-github-ci/releases/download/0.2.0/zeroc_ice-3.6.5-cp310-cp310-linux_x86_64.whl; platform_system=="Linux" and python_version=="3.10" + https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20231024/zeroc_ice-3.6.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; platform_system=="Linux" and python_version=="3.11" mox3 setenv = ICE_CONFIG = {toxinidir}/ice.config From 1b04d005506d20249d661bbce5eb9122685e6c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Besson?= Date: Thu, 26 Oct 2023 16:28:16 +0100 Subject: [PATCH 2/5] Replace all usages of mox3 by pytest-mock Also re-enable most unit tests currently marked as broken --- .omeroci/scripts-copy | 1 - test/drivers.py | 9 ++------- test/unit/test_monitor.py | 16 ++++++++-------- test/unit/test_state.py | 16 +++------------- tox.ini | 2 +- 5 files changed, 14 insertions(+), 30 deletions(-) diff --git a/.omeroci/scripts-copy b/.omeroci/scripts-copy index e4d0b73..1e7ccab 100755 --- a/.omeroci/scripts-copy +++ b/.omeroci/scripts-copy @@ -7,4 +7,3 @@ set -x cd $TARGET echo No-op: scripts could potentially be renamed to "core" or "internal" -/opt/omero/server/venv3/bin/pip install mox3 diff --git a/test/drivers.py b/test/drivers.py index a621a2c..da9388b 100644 --- a/test/drivers.py +++ b/test/drivers.py @@ -29,7 +29,6 @@ # Python 2 from path import path from omero.util import ServerContext -from mox3 import mox from functools import wraps from omero.util.temp_files import create_path from fsDropBoxMonitorClient import MonitorClientI @@ -352,15 +351,10 @@ def addObjectFactory(self, *args): class MockServerContext(ServerContext): def __init__(self, ic, get_root): - self.mox = mox.Mox() self.communicator = ic self.getSession = get_root self.stop_event = threading.Event() - def newSession(self, *args): - sess = self.mox.CreateMock(omero.api.ServiceFactoryPrx.__class__) - return sess - class MockMonitor(MonitorClientI): @@ -381,9 +375,10 @@ def __init__(self, dir=None, pre=None, post=None): post = [] self.root = None ic = mock_communicator() + self.ctx = MockServerContext(ic, self.get_root) MonitorClientI.__init__( self, dir, ic, getUsedFiles=self.used_files, - ctx=MockServerContext(ic, self.get_root), worker_wait=0.1) + ctx=self.ctx, worker_wait=0.1) self.log = logging.getLogger("MockMonitor") self.events = [] self.files = {} diff --git a/test/unit/test_monitor.py b/test/unit/test_monitor.py index 5c699f1..530a317 100644 --- a/test/unit/test_monitor.py +++ b/test/unit/test_monitor.py @@ -41,17 +41,17 @@ def testBadFileId(self): def testEmptyAdd(self): MockMonitor().fsEventHappened('', []) # Does nothing. - @pytest.mark.broken(ticket="12566") @with_driver - def testBasicAdd(self): + def testBasicAdd(self, mocker): + mocker.patch.object(self.client.ctx,'newSession', autospec=True) self.driver.add(DirInfoEvent(1, monitors.EventInfo( self.dir / "root" / "dirtimeout", monitors.EventType.Create))) self.driver.run() - @pytest.mark.broken(ticket="12566") @with_driver - def testWithSingleImport(self): + def testWithSingleImport(self, mocker): + mocker.patch.object(self.client.ctx,'newSession', autospec=True) f = self.dir / "root" / "file" self.client.files = {str(f): [str(f)]} self.driver.add(DirInfoEvent(0, monitors.EventInfo( @@ -59,9 +59,9 @@ def testWithSingleImport(self): self.driver.run() time.sleep(0.25) - @pytest.mark.broken(ticket="12566") @with_driver - def testWithMultiImport(self): + def testWithMultiImport(self, mocker): + mocker.patch.object(self.client.ctx,'newSession', autospec=True) f1 = str(self.dir / "root" / "file1") f2 = str(self.dir / "root" / "file2") f3 = str(self.dir / "root" / "file3") @@ -79,9 +79,9 @@ def testWithMultiImport(self): time.sleep(1) self.driver.run() - @pytest.mark.broken(ticket="12566") @with_driver - def testDirectoryInDirectory(self): + def testDirectoryInDirectory(self, mocker): + mocker.patch.object(self.client.ctx,'newSession', autospec=True) self.driver.add(DirInfoEvent(1, monitors.EventInfo( self.dir / "root" / "dir", monitors.EventType.Create))) self.driver.add(DirInfoEvent(1, monitors.EventInfo( diff --git a/test/unit/test_state.py b/test/unit/test_state.py index d613ef5..2df46d5 100644 --- a/test/unit/test_state.py +++ b/test/unit/test_state.py @@ -44,28 +44,24 @@ def cb(*args): class TestState(object): def setup_method(self, method): - self.s = fsDBMC.MonitorState() + self.s = fsDBMC.MonitorState(None) self.log = logging.getLogger(make_logname(self)) def teardown_method(self, method): self.s.stop() - @pytest.mark.broken(ticket="12566") def testEmpty(self): self.s.update({}, 0, nullcb) - @pytest.mark.broken(ticket="12566") def testSimple(self): self.s.update({'file1': ['file1', 'file2']}, 0, nullcb) - @pytest.mark.broken(ticket="12566") def testTimerCalled(self): l = [] self.s.update({'file1': ['file1', 'file2']}, 0, listcb(l)) time.sleep(0.25) assert 1 == len(l) - @pytest.mark.broken(ticket="12566") def testMultipleInsert(self): l = [] m = { @@ -77,7 +73,6 @@ def testMultipleInsert(self): time.sleep(0.25) assert 1 == len(l) - @pytest.mark.broken(ticket="12566") def testAddThenReAdd(self): l = [] self.s.update({'file1': ['file1', 'file2']}, 0.1, listcb(l)) @@ -85,7 +80,6 @@ def testAddThenReAdd(self): time.sleep(0.25) assert 1 == len(l) - @pytest.mark.broken(ticket="12566") def testAddThenModify(self): l = [] self.s.update({'file1': ['file1', 'file2']}, 0.1, listcb(l)) @@ -93,17 +87,15 @@ def testAddThenModify(self): time.sleep(0.25) assert 1 == len(l) - @pytest.mark.broken(ticket="12566") def testEntryMoved1(self): l = [] self.s.update({'file1': ['file1']}, 0.1, listcb(l)) - assert 1 == list(self.s.keys()) + assert 1 == len(list(self.s.keys())) self.s.update({'file2': ['file1', 'file2']}, 0.1, listcb(l)) - assert 2 == list(self.s.keys()) + assert 2 == len(list(self.s.keys())) time.sleep(0.25) assert 1 == len(l) - @pytest.mark.broken(ticket="12566") def testEntryMoved2(self): self.s.update( {'file1': ['file1']}, 0.1, clearcb(self.log, self.s, 'file1')) @@ -118,7 +110,6 @@ def testEntryMoved2(self): assert 0 == len(list(self.s.keys())) assert 0 == self.s.count() - @pytest.mark.broken(ticket="12566") def testEntryOutOfSyncSubsume(self): self.s.update({'file1': ['file1']}, 0.1, nullcb) assert 1 == len(list(self.s.keys())) @@ -127,7 +118,6 @@ def testEntryOutOfSyncSubsume(self): self.s.update({'file2': ['file1', 'file2']}, 0.1, nullcb) assert 2 == len(list(self.s.keys())) - @pytest.mark.broken(ticket="12566") def testEntryOutOfSyncSteal(self): self.s.update({'file1': ['file1', 'file3']}, 0.1, nullcb) assert 2 == len(list(self.s.keys())) diff --git a/tox.ini b/tox.ini index 40bc674..d47b7f5 100644 --- a/tox.ini +++ b/tox.ini @@ -9,12 +9,12 @@ deps = future numpy pytest + pytest-mock restructuredtext-lint https://github.com/ome/zeroc-ice-py-github-ci/releases/download/0.2.0/zeroc_ice-3.6.5-cp38-cp38-linux_x86_64.whl; platform_system=="Linux" and python_version=="3.8" https://github.com/ome/zeroc-ice-py-github-ci/releases/download/0.2.0/zeroc_ice-3.6.5-cp39-cp39-linux_x86_64.whl; platform_system=="Linux" and python_version=="3.9" https://github.com/ome/zeroc-ice-py-github-ci/releases/download/0.2.0/zeroc_ice-3.6.5-cp310-cp310-linux_x86_64.whl; platform_system=="Linux" and python_version=="3.10" https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20231024/zeroc_ice-3.6.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; platform_system=="Linux" and python_version=="3.11" - mox3 setenv = ICE_CONFIG = {toxinidir}/ice.config passenv = From 88f18be400fda1e962c69d0a1179a2ebfb0fe9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Besson?= Date: Thu, 26 Oct 2023 16:29:00 +0100 Subject: [PATCH 3/5] Add Python 3.11 to Tox GitHub workflow --- .github/workflows/tox.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 0aa2749..cb0b4c8 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -16,6 +16,7 @@ jobs: - '3.8' - '3.9' - '3.10' + - '3.11' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 71c3268337a92c5e2739e409a19d73a18dfe3e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Besson?= Date: Fri, 27 Oct 2023 12:25:31 +0100 Subject: [PATCH 4/5] Add pytest-mock to the test requirements --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index aff174e..46f7aab 100755 --- a/setup.py +++ b/setup.py @@ -55,4 +55,4 @@ def read(fname): "omero-py", # requires Ice (use wheel for faster installs) ], python_requires='>=3', - tests_require=['pytest']) + tests_require=['pytest', 'pytest-mock']) From b9176636094841ba7c81dd7b06d9a2c46ca0ce0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Besson?= Date: Mon, 27 Nov 2023 08:38:51 +0000 Subject: [PATCH 5/5] Use ubuntu-22.04 --- .github/workflows/tox.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index cb0b4c8..d25dee2 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -17,7 +17,7 @@ jobs: - '3.9' - '3.10' - '3.11' - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4