From 2620d91a85ee5ef97155cc4e1e46208eb85ad774 Mon Sep 17 00:00:00 2001 From: Attila Somogyi Date: Wed, 11 Dec 2024 13:17:19 +0000 Subject: [PATCH 1/2] Adding OCR sdk proxy implementation. --- otcextensions/sdk/__init__.py | 3 +++ otcextensions/sdk/ocr/__init__.py | 0 otcextensions/sdk/ocr/ocr_service.py | 22 +++++++++++++++++++ otcextensions/sdk/ocr/v2/__init__.py | 0 otcextensions/sdk/ocr/v2/_proxy.py | 17 ++++++++++++++ otcextensions/tests/unit/sdk/ocr/__init__.py | 0 .../tests/unit/sdk/ocr/v2/__init__.py | 0 .../tests/unit/sdk/ocr/v2/test_proxy.py | 22 +++++++++++++++++++ .../notes/ocr_sdk_proxy-c4cd12d963a7aa13.yaml | 3 +++ 9 files changed, 67 insertions(+) create mode 100644 otcextensions/sdk/ocr/__init__.py create mode 100644 otcextensions/sdk/ocr/ocr_service.py create mode 100644 otcextensions/sdk/ocr/v2/__init__.py create mode 100644 otcextensions/sdk/ocr/v2/_proxy.py create mode 100644 otcextensions/tests/unit/sdk/ocr/__init__.py create mode 100644 otcextensions/tests/unit/sdk/ocr/v2/__init__.py create mode 100644 otcextensions/tests/unit/sdk/ocr/v2/test_proxy.py create mode 100644 releasenotes/notes/ocr_sdk_proxy-c4cd12d963a7aa13.yaml diff --git a/otcextensions/sdk/__init__.py b/otcextensions/sdk/__init__.py index 207ca2904..ffea0e33c 100644 --- a/otcextensions/sdk/__init__.py +++ b/otcextensions/sdk/__init__.py @@ -207,6 +207,9 @@ 'endpoint_service_type': 'object', 'set_endpoint_override': True }, + 'ocr': { + 'service_type': 'ocr', + }, 'plas': { 'service_type': 'plas' }, diff --git a/otcextensions/sdk/ocr/__init__.py b/otcextensions/sdk/ocr/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/sdk/ocr/ocr_service.py b/otcextensions/sdk/ocr/ocr_service.py new file mode 100644 index 000000000..ab60ee24f --- /dev/null +++ b/otcextensions/sdk/ocr/ocr_service.py @@ -0,0 +1,22 @@ +# 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. +from openstack import service_description + +from otcextensions.sdk.ocr.v2 import _proxy + + +class OcrService(service_description.ServiceDescription): + """The Optical Character Recognition (OCR) service.""" + + supported_versions = { + '2': _proxy.Proxy + } diff --git a/otcextensions/sdk/ocr/v2/__init__.py b/otcextensions/sdk/ocr/v2/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/sdk/ocr/v2/_proxy.py b/otcextensions/sdk/ocr/v2/_proxy.py new file mode 100644 index 000000000..38cfb42e8 --- /dev/null +++ b/otcextensions/sdk/ocr/v2/_proxy.py @@ -0,0 +1,17 @@ +# 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. +from openstack import proxy + + +class Proxy(proxy.Proxy): + + skip_discovery = True diff --git a/otcextensions/tests/unit/sdk/ocr/__init__.py b/otcextensions/tests/unit/sdk/ocr/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/tests/unit/sdk/ocr/v2/__init__.py b/otcextensions/tests/unit/sdk/ocr/v2/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/tests/unit/sdk/ocr/v2/test_proxy.py b/otcextensions/tests/unit/sdk/ocr/v2/test_proxy.py new file mode 100644 index 000000000..5a975c49e --- /dev/null +++ b/otcextensions/tests/unit/sdk/ocr/v2/test_proxy.py @@ -0,0 +1,22 @@ +# 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. + +from otcextensions.sdk.ocr.v2 import _proxy + +from openstack.tests.unit import test_proxy_base + + +class TestOcrProxy(test_proxy_base.TestProxyBase): + + def setUp(self): + super(TestOcrProxy, self).setUp() + self.proxy = _proxy.Proxy(self.session) diff --git a/releasenotes/notes/ocr_sdk_proxy-c4cd12d963a7aa13.yaml b/releasenotes/notes/ocr_sdk_proxy-c4cd12d963a7aa13.yaml new file mode 100644 index 000000000..4a8eed9fb --- /dev/null +++ b/releasenotes/notes/ocr_sdk_proxy-c4cd12d963a7aa13.yaml @@ -0,0 +1,3 @@ +--- +features: + - Added OCR sdk proxy implementation. From 481bafbe6ed22180d58633d56da0f3a90586796f Mon Sep 17 00:00:00 2001 From: Attila Somogyi Date: Fri, 13 Dec 2024 13:13:57 +0000 Subject: [PATCH 2/2] Added sdk functional OCR proxy connection test --- .../tests/functional/sdk/ocr/__init__.py | 0 .../tests/functional/sdk/ocr/v2/__init__.py | 0 .../functional/sdk/ocr/v2/test_service.py | 23 +++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 otcextensions/tests/functional/sdk/ocr/__init__.py create mode 100644 otcextensions/tests/functional/sdk/ocr/v2/__init__.py create mode 100644 otcextensions/tests/functional/sdk/ocr/v2/test_service.py diff --git a/otcextensions/tests/functional/sdk/ocr/__init__.py b/otcextensions/tests/functional/sdk/ocr/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/tests/functional/sdk/ocr/v2/__init__.py b/otcextensions/tests/functional/sdk/ocr/v2/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/otcextensions/tests/functional/sdk/ocr/v2/test_service.py b/otcextensions/tests/functional/sdk/ocr/v2/test_service.py new file mode 100644 index 000000000..e0de6e553 --- /dev/null +++ b/otcextensions/tests/functional/sdk/ocr/v2/test_service.py @@ -0,0 +1,23 @@ +# 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. +from openstack import _log +from otcextensions.tests.functional import base + +_logger = _log.setup_logging('openstack') + + +class TestService(base.BaseFunctionalTest): + + def test_initialize(self): + client = self.conn.ocr + + self.assertIsNotNone(client)