port-ocean 0.15.0__py3-none-any.whl → 0.15.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of port-ocean might be problematic. Click here for more details.
- port_ocean/core/models.py +13 -2
- port_ocean/core/utils.py +5 -3
- port_ocean/tests/core/test_utils.py +73 -0
- {port_ocean-0.15.0.dist-info → port_ocean-0.15.2.dist-info}/METADATA +1 -1
- {port_ocean-0.15.0.dist-info → port_ocean-0.15.2.dist-info}/RECORD +8 -7
- {port_ocean-0.15.0.dist-info → port_ocean-0.15.2.dist-info}/LICENSE.md +0 -0
- {port_ocean-0.15.0.dist-info → port_ocean-0.15.2.dist-info}/WHEEL +0 -0
- {port_ocean-0.15.0.dist-info → port_ocean-0.15.2.dist-info}/entry_points.txt +0 -0
port_ocean/core/models.py
CHANGED
|
@@ -8,12 +8,23 @@ from pydantic.fields import Field
|
|
|
8
8
|
|
|
9
9
|
class Runtime(Enum):
|
|
10
10
|
Saas = "Saas"
|
|
11
|
-
SaasOauth = "SaasOauth"
|
|
12
11
|
OnPrem = "OnPrem"
|
|
13
12
|
|
|
14
13
|
@property
|
|
15
14
|
def is_saas_runtime(self) -> bool:
|
|
16
|
-
return self in [Runtime.Saas
|
|
15
|
+
return self in [Runtime.Saas]
|
|
16
|
+
|
|
17
|
+
def is_installation_type_compatible(self, installation_type: str) -> bool:
|
|
18
|
+
"""
|
|
19
|
+
Check if the installation type is compatible with the runtime
|
|
20
|
+
|
|
21
|
+
if the runtime is Saas, the installation type should start with Saas
|
|
22
|
+
else the installation type should be OnPrem
|
|
23
|
+
"""
|
|
24
|
+
return (
|
|
25
|
+
self.value == Runtime.Saas.value
|
|
26
|
+
and installation_type.startswith(self.value)
|
|
27
|
+
) or installation_type == self.value
|
|
17
28
|
|
|
18
29
|
|
|
19
30
|
class Entity(BaseModel):
|
port_ocean/core/utils.py
CHANGED
|
@@ -42,10 +42,12 @@ async def validate_integration_runtime(
|
|
|
42
42
|
current_integration = await port_client.get_current_integration(
|
|
43
43
|
should_raise=False, should_log=False
|
|
44
44
|
)
|
|
45
|
-
|
|
46
|
-
if current_integration and
|
|
45
|
+
current_installation_type = current_integration.get("installationType", "OnPrem")
|
|
46
|
+
if current_integration and not requested_runtime.is_installation_type_compatible(
|
|
47
|
+
current_installation_type
|
|
48
|
+
):
|
|
47
49
|
raise IntegrationRuntimeException(
|
|
48
|
-
f"Invalid Runtime! Requested to run existing {
|
|
50
|
+
f"Invalid Runtime! Requested to run existing {current_installation_type} integration in {requested_runtime} runtime."
|
|
49
51
|
)
|
|
50
52
|
|
|
51
53
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from unittest.mock import AsyncMock, patch
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from port_ocean.core.utils import validate_integration_runtime
|
|
6
|
+
from port_ocean.clients.port.client import PortClient
|
|
7
|
+
from port_ocean.core.models import Runtime
|
|
8
|
+
from port_ocean.tests.helpers.port_client import get_port_client_for_integration
|
|
9
|
+
from port_ocean.exceptions.core import IntegrationRuntimeException
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TestValidateIntegrationRuntime:
|
|
13
|
+
|
|
14
|
+
@pytest.mark.asyncio
|
|
15
|
+
@pytest.mark.parametrize(
|
|
16
|
+
"requested_runtime, installation_type, should_raise",
|
|
17
|
+
[
|
|
18
|
+
(Runtime.Saas, "Saas", False),
|
|
19
|
+
(Runtime.Saas, "SaasOauth2", False),
|
|
20
|
+
(Runtime.Saas, "OnPrem", True),
|
|
21
|
+
(Runtime.OnPrem, "OnPrem", False),
|
|
22
|
+
(Runtime.OnPrem, "SaasOauth2", True),
|
|
23
|
+
],
|
|
24
|
+
)
|
|
25
|
+
@patch.object(PortClient, "get_current_integration", new_callable=AsyncMock)
|
|
26
|
+
async def test_validate_integration_runtime(
|
|
27
|
+
self,
|
|
28
|
+
mock_get_current_integration: AsyncMock,
|
|
29
|
+
requested_runtime: Runtime,
|
|
30
|
+
installation_type: str,
|
|
31
|
+
should_raise: bool,
|
|
32
|
+
) -> None:
|
|
33
|
+
# Arrange
|
|
34
|
+
port_client = get_port_client_for_integration(
|
|
35
|
+
client_id="mock-client-id",
|
|
36
|
+
client_secret="mock-client-secret",
|
|
37
|
+
integration_identifier="mock-integration-identifier",
|
|
38
|
+
integration_type="mock-integration-type",
|
|
39
|
+
integration_version="mock-integration-version",
|
|
40
|
+
base_url="mock-base-url",
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Mock the return value of get_current_integration
|
|
44
|
+
mock_get_current_integration.return_value = {
|
|
45
|
+
"installationType": installation_type
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# Act & Assert
|
|
49
|
+
if should_raise:
|
|
50
|
+
with pytest.raises(IntegrationRuntimeException):
|
|
51
|
+
await validate_integration_runtime(port_client, requested_runtime)
|
|
52
|
+
else:
|
|
53
|
+
await validate_integration_runtime(port_client, requested_runtime)
|
|
54
|
+
|
|
55
|
+
# Verify that get_current_integration was called once
|
|
56
|
+
mock_get_current_integration.assert_called_once()
|
|
57
|
+
|
|
58
|
+
@pytest.mark.parametrize(
|
|
59
|
+
"requested_runtime, installation_type, expected",
|
|
60
|
+
[
|
|
61
|
+
(Runtime.Saas, "SaasOauth2", True),
|
|
62
|
+
(Runtime.Saas, "OnPrem", False),
|
|
63
|
+
(Runtime.OnPrem, "OnPrem", True),
|
|
64
|
+
(Runtime.OnPrem, "SaasCloud", False),
|
|
65
|
+
],
|
|
66
|
+
)
|
|
67
|
+
def test_runtime_installation_compatibility(
|
|
68
|
+
self, requested_runtime: Runtime, installation_type: str, expected: bool
|
|
69
|
+
) -> None:
|
|
70
|
+
assert (
|
|
71
|
+
requested_runtime.is_installation_type_compatible(installation_type)
|
|
72
|
+
== expected
|
|
73
|
+
)
|
|
@@ -102,9 +102,9 @@ port_ocean/core/integrations/mixins/handler.py,sha256=mZ7-0UlG3LcrwJttFbMe-R4xcO
|
|
|
102
102
|
port_ocean/core/integrations/mixins/sync.py,sha256=B9fEs8faaYLLikH9GBjE_E61vo0bQDjIGQsQ1SRXOlA,3931
|
|
103
103
|
port_ocean/core/integrations/mixins/sync_raw.py,sha256=BGS5EnZ2N3ifcAi94Wo-ZassSJ-_Se9eFJMpBDT7pNY,18841
|
|
104
104
|
port_ocean/core/integrations/mixins/utils.py,sha256=7y1rGETZIjOQadyIjFJXIHKkQFKx_SwiP-TrAIsyyLY,2303
|
|
105
|
-
port_ocean/core/models.py,sha256=
|
|
105
|
+
port_ocean/core/models.py,sha256=71QIFHl-p401h2HnSDQ-aaLXhu6z3iHTwCBI0TewJos,1902
|
|
106
106
|
port_ocean/core/ocean_types.py,sha256=3_d8-n626f1kWLQ_Jxw194LEyrOVupz05qs_Y1pvB-A,990
|
|
107
|
-
port_ocean/core/utils.py,sha256=
|
|
107
|
+
port_ocean/core/utils.py,sha256=QSRuF9wlhbOw6cELlDlek_UIX6ciIuKWml8QhBmHU_k,3703
|
|
108
108
|
port_ocean/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
109
109
|
port_ocean/exceptions/api.py,sha256=TLmTMqn4uHGaHgZK8PMIJ0TVJlPB4iP7xl9rx7GtCyY,426
|
|
110
110
|
port_ocean/exceptions/base.py,sha256=uY4DX7fIITDFfemCJDWpaZi3bD51lcANc5swpoNvMJA,46
|
|
@@ -130,6 +130,7 @@ port_ocean/tests/clients/port/mixins/test_entities.py,sha256=A9myrnkLhKSQrnOLv1Z
|
|
|
130
130
|
port_ocean/tests/conftest.py,sha256=JXASSS0IY0nnR6bxBflhzxS25kf4iNaABmThyZ0mZt8,101
|
|
131
131
|
port_ocean/tests/core/defaults/test_common.py,sha256=sR7RqB3ZYV6Xn6NIg-c8k5K6JcGsYZ2SCe_PYX5vLYM,5560
|
|
132
132
|
port_ocean/tests/core/handlers/entity_processor/test_jq_entity_processor.py,sha256=Yv03P-LDcJCKZ21exiTFrcT1eu0zn6Z954dilxrb52Y,10842
|
|
133
|
+
port_ocean/tests/core/test_utils.py,sha256=94940TerN38jy81ebLJ2Fzf5JJUaV9krnce75APCwmM,2641
|
|
133
134
|
port_ocean/tests/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
134
135
|
port_ocean/tests/helpers/fake_port_api.py,sha256=9rtjC6iTQMfzWK6WipkDzzG0b1IIaRmvdJLOyV613vE,6479
|
|
135
136
|
port_ocean/tests/helpers/fixtures.py,sha256=IQEplbHhRgjrAsZlnXrgSYA5YQEn25I9HgO3_Fjibxg,1481
|
|
@@ -151,8 +152,8 @@ port_ocean/utils/repeat.py,sha256=0EFWM9d8lLXAhZmAyczY20LAnijw6UbIECf5lpGbOas,32
|
|
|
151
152
|
port_ocean/utils/signal.py,sha256=K-6kKFQTltcmKDhtyZAcn0IMa3sUpOHGOAUdWKgx0_E,1369
|
|
152
153
|
port_ocean/utils/time.py,sha256=pufAOH5ZQI7gXvOvJoQXZXZJV-Dqktoj9Qp9eiRwmJ4,1939
|
|
153
154
|
port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
|
|
154
|
-
port_ocean-0.15.
|
|
155
|
-
port_ocean-0.15.
|
|
156
|
-
port_ocean-0.15.
|
|
157
|
-
port_ocean-0.15.
|
|
158
|
-
port_ocean-0.15.
|
|
155
|
+
port_ocean-0.15.2.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
156
|
+
port_ocean-0.15.2.dist-info/METADATA,sha256=xiclpeTv7njo_QsJHJVG3NF6g-PSh74WwovQQYjwX6w,6673
|
|
157
|
+
port_ocean-0.15.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
158
|
+
port_ocean-0.15.2.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
|
|
159
|
+
port_ocean-0.15.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|