port-ocean 0.20.4__py3-none-any.whl → 0.21.1__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/cli/cookiecutter/hooks/post_gen_project.py +1 -1
- port_ocean/context/event.py +7 -2
- port_ocean/context/ocean.py +37 -1
- port_ocean/core/defaults/initialize.py +2 -4
- port_ocean/core/integrations/mixins/events.py +38 -34
- port_ocean/core/integrations/mixins/sync_raw.py +14 -1
- port_ocean/core/ocean_types.py +5 -0
- port_ocean/tests/core/handlers/mixins/test_sync_raw.py +174 -0
- {port_ocean-0.20.4.dist-info → port_ocean-0.21.1.dist-info}/METADATA +1 -1
- {port_ocean-0.20.4.dist-info → port_ocean-0.21.1.dist-info}/RECORD +13 -13
- {port_ocean-0.20.4.dist-info → port_ocean-0.21.1.dist-info}/LICENSE.md +0 -0
- {port_ocean-0.20.4.dist-info → port_ocean-0.21.1.dist-info}/WHEEL +0 -0
- {port_ocean-0.20.4.dist-info → port_ocean-0.21.1.dist-info}/entry_points.txt +0 -0
|
@@ -8,7 +8,7 @@ def handle_private_integration_flags():
|
|
|
8
8
|
)
|
|
9
9
|
root_dir = os.path.join("{{ cookiecutter._repo_dir }}", "../../../")
|
|
10
10
|
infra_make_file = os.path.join(root_dir, "integrations/_infra/Makefile")
|
|
11
|
-
infra_dockerfile = os.path.join(root_dir, "integrations/_infra/Dockerfile.
|
|
11
|
+
infra_dockerfile = os.path.join(root_dir, "integrations/_infra/Dockerfile.Deb")
|
|
12
12
|
infra_dockerignore = os.path.join(
|
|
13
13
|
root_dir, "integrations/_infra/Dockerfile.dockerignore"
|
|
14
14
|
)
|
port_ocean/context/event.py
CHANGED
|
@@ -182,9 +182,14 @@ async def event_context(
|
|
|
182
182
|
f"Skipping resync due to empty mapping: {str(e)}", exc_info=True
|
|
183
183
|
)
|
|
184
184
|
raise
|
|
185
|
-
except
|
|
185
|
+
except BaseException as e:
|
|
186
186
|
success = False
|
|
187
|
-
|
|
187
|
+
if isinstance(e, KeyboardInterrupt):
|
|
188
|
+
logger.warning("Operation interrupted by user", exc_info=True)
|
|
189
|
+
elif isinstance(e, asyncio.CancelledError):
|
|
190
|
+
logger.warning("Operation was cancelled", exc_info=True)
|
|
191
|
+
else:
|
|
192
|
+
logger.error(f"Event failed with error: {repr(e)}", exc_info=True)
|
|
188
193
|
raise
|
|
189
194
|
else:
|
|
190
195
|
success = True
|
port_ocean/context/ocean.py
CHANGED
|
@@ -12,6 +12,8 @@ from port_ocean.core.ocean_types import (
|
|
|
12
12
|
START_EVENT_LISTENER,
|
|
13
13
|
RawEntityDiff,
|
|
14
14
|
EntityDiff,
|
|
15
|
+
BEFORE_RESYNC_EVENT_LISTENER,
|
|
16
|
+
AFTER_RESYNC_EVENT_LISTENER,
|
|
15
17
|
)
|
|
16
18
|
from port_ocean.exceptions.context import (
|
|
17
19
|
PortOceanContextNotFoundError,
|
|
@@ -80,7 +82,7 @@ class PortOceanContext:
|
|
|
80
82
|
) -> RESYNC_EVENT_LISTENER | None:
|
|
81
83
|
if not self.app.config.event_listener.should_resync:
|
|
82
84
|
logger.debug(
|
|
83
|
-
"
|
|
85
|
+
f"Using event listener {self.app.config.event_listener.type}, which shouldn't perform any resyncs. Skipping resyncs setup..."
|
|
84
86
|
)
|
|
85
87
|
return None
|
|
86
88
|
return self.integration.on_resync(function, kind)
|
|
@@ -93,6 +95,40 @@ class PortOceanContext:
|
|
|
93
95
|
|
|
94
96
|
return wrapper
|
|
95
97
|
|
|
98
|
+
def on_resync_start(
|
|
99
|
+
self,
|
|
100
|
+
) -> Callable[
|
|
101
|
+
[BEFORE_RESYNC_EVENT_LISTENER | None], BEFORE_RESYNC_EVENT_LISTENER | None
|
|
102
|
+
]:
|
|
103
|
+
def wrapper(
|
|
104
|
+
function: BEFORE_RESYNC_EVENT_LISTENER | None,
|
|
105
|
+
) -> BEFORE_RESYNC_EVENT_LISTENER | None:
|
|
106
|
+
if not self.app.config.event_listener.should_resync:
|
|
107
|
+
logger.debug(
|
|
108
|
+
f"Using event listener {self.app.config.event_listener.type}, which shouldn't perform any resyncs. Skipping resyncs setup..."
|
|
109
|
+
)
|
|
110
|
+
return None
|
|
111
|
+
return self.integration.on_resync_start(function)
|
|
112
|
+
|
|
113
|
+
return wrapper
|
|
114
|
+
|
|
115
|
+
def on_resync_complete(
|
|
116
|
+
self,
|
|
117
|
+
) -> Callable[
|
|
118
|
+
[AFTER_RESYNC_EVENT_LISTENER | None], AFTER_RESYNC_EVENT_LISTENER | None
|
|
119
|
+
]:
|
|
120
|
+
def wrapper(
|
|
121
|
+
function: AFTER_RESYNC_EVENT_LISTENER | None,
|
|
122
|
+
) -> AFTER_RESYNC_EVENT_LISTENER | None:
|
|
123
|
+
if not self.app.config.event_listener.should_resync:
|
|
124
|
+
logger.debug(
|
|
125
|
+
f"Using event listener {self.app.config.event_listener.type}, which shouldn't perform any resyncs. Skipping resyncs setup..."
|
|
126
|
+
)
|
|
127
|
+
return None
|
|
128
|
+
return self.integration.on_resync_complete(function)
|
|
129
|
+
|
|
130
|
+
return wrapper
|
|
131
|
+
|
|
96
132
|
async def update_raw_diff(
|
|
97
133
|
self,
|
|
98
134
|
kind: str,
|
|
@@ -208,9 +208,6 @@ async def _create_resources(
|
|
|
208
208
|
async def _initialize_defaults(
|
|
209
209
|
config_class: Type[PortAppConfig], integration_config: IntegrationConfiguration
|
|
210
210
|
) -> None:
|
|
211
|
-
if not integration_config.initialize_port_resources:
|
|
212
|
-
return
|
|
213
|
-
|
|
214
211
|
port_client = ocean.port_client
|
|
215
212
|
defaults = get_port_integration_defaults(
|
|
216
213
|
config_class, integration_config.resources_path
|
|
@@ -274,9 +271,10 @@ async def _initialize_defaults(
|
|
|
274
271
|
if (
|
|
275
272
|
integration_config.create_port_resources_origin
|
|
276
273
|
== CreatePortResourcesOrigin.Port
|
|
274
|
+
or not integration_config.initialize_port_resources
|
|
277
275
|
):
|
|
278
276
|
logger.info(
|
|
279
|
-
"Skipping creating defaults resources due to `create_port_resources_origin` being `Port`"
|
|
277
|
+
"Skipping creating defaults resources due to `create_port_resources_origin` being `Port` or `initialize_port_resources` being `false`"
|
|
280
278
|
)
|
|
281
279
|
return
|
|
282
280
|
try:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from collections import defaultdict
|
|
2
|
+
from typing import Any
|
|
2
3
|
|
|
3
4
|
from loguru import logger
|
|
4
5
|
|
|
@@ -6,6 +7,8 @@ from port_ocean.core.ocean_types import (
|
|
|
6
7
|
IntegrationEventsCallbacks,
|
|
7
8
|
START_EVENT_LISTENER,
|
|
8
9
|
RESYNC_EVENT_LISTENER,
|
|
10
|
+
BEFORE_RESYNC_EVENT_LISTENER,
|
|
11
|
+
AFTER_RESYNC_EVENT_LISTENER,
|
|
9
12
|
)
|
|
10
13
|
|
|
11
14
|
|
|
@@ -13,55 +16,56 @@ class EventsMixin:
|
|
|
13
16
|
"""A mixin class that provides event handling capabilities for the integration class.
|
|
14
17
|
|
|
15
18
|
This mixin allows classes to register event listeners and manage event callbacks.
|
|
16
|
-
It provides methods for attaching listeners to
|
|
19
|
+
It provides methods for attaching listeners to various lifecycle events.
|
|
17
20
|
|
|
18
21
|
Attributes:
|
|
19
|
-
event_strategy
|
|
20
|
-
- "start": List of functions to be called on "start" event.
|
|
21
|
-
- "resync": Default dictionary mapping event kinds to lists of functions
|
|
22
|
-
to be called on "resync" events of the specified kind.
|
|
22
|
+
event_strategy: A dictionary storing event callbacks for different event types.
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
25
|
def __init__(self) -> None:
|
|
26
26
|
self.event_strategy: IntegrationEventsCallbacks = {
|
|
27
27
|
"start": [],
|
|
28
28
|
"resync": defaultdict(list),
|
|
29
|
+
"resync_start": [],
|
|
30
|
+
"resync_complete": [],
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
@property
|
|
32
34
|
def available_resync_kinds(self) -> list[str]:
|
|
33
35
|
return list(self.event_strategy["resync"].keys())
|
|
34
36
|
|
|
35
|
-
def on_start(self,
|
|
36
|
-
"""Register a function as a listener for the "start" event.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Returns:
|
|
42
|
-
START_EVENT_LISTENER: The input function, unchanged.
|
|
43
|
-
"""
|
|
44
|
-
logger.debug(f"Registering {func} as a start event listener")
|
|
45
|
-
self.event_strategy["start"].append(func)
|
|
46
|
-
return func
|
|
37
|
+
def on_start(self, function: START_EVENT_LISTENER) -> START_EVENT_LISTENER:
|
|
38
|
+
"""Register a function as a listener for the "start" event."""
|
|
39
|
+
logger.debug(f"Registering {function} as a start event listener")
|
|
40
|
+
self.event_strategy["start"].append(function)
|
|
41
|
+
return function
|
|
47
42
|
|
|
48
43
|
def on_resync(
|
|
49
|
-
self,
|
|
50
|
-
) -> RESYNC_EVENT_LISTENER:
|
|
51
|
-
"""Register a function as a listener for a "resync" event.
|
|
44
|
+
self, function: RESYNC_EVENT_LISTENER | None, kind: str | None = None
|
|
45
|
+
) -> RESYNC_EVENT_LISTENER | None:
|
|
46
|
+
"""Register a function as a listener for a "resync" event."""
|
|
47
|
+
if function is not None:
|
|
48
|
+
if kind is None:
|
|
49
|
+
logger.debug("Registering resync event listener any kind")
|
|
50
|
+
else:
|
|
51
|
+
logger.info(f"Registering resync event listener for kind {kind}")
|
|
52
|
+
self.event_strategy["resync"][kind].append(function)
|
|
53
|
+
return function
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
def on_resync_start(
|
|
56
|
+
self, function: BEFORE_RESYNC_EVENT_LISTENER | None
|
|
57
|
+
) -> BEFORE_RESYNC_EVENT_LISTENER | None:
|
|
58
|
+
"""Register a function to be called when a resync operation starts."""
|
|
59
|
+
if function is not None:
|
|
60
|
+
logger.debug(f"Registering {function} as a resync_start event listener")
|
|
61
|
+
self.event_strategy["resync_start"].append(function)
|
|
62
|
+
return function
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
logger.info(f"Registering resync event listener for kind {kind}")
|
|
66
|
-
self.event_strategy["resync"][kind].append(func)
|
|
67
|
-
return func
|
|
64
|
+
def on_resync_complete(
|
|
65
|
+
self, function: AFTER_RESYNC_EVENT_LISTENER | None
|
|
66
|
+
) -> AFTER_RESYNC_EVENT_LISTENER | None:
|
|
67
|
+
"""Register a function to be called when a resync operation completes."""
|
|
68
|
+
if function is not None:
|
|
69
|
+
logger.debug(f"Registering {function} as a resync_complete event listener")
|
|
70
|
+
self.event_strategy["resync_complete"].append(function)
|
|
71
|
+
return function
|
|
@@ -550,6 +550,10 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
|
|
|
550
550
|
)
|
|
551
551
|
logger.info(f"Resync will use the following mappings: {app_config.dict()}")
|
|
552
552
|
|
|
553
|
+
# Execute resync_start hooks
|
|
554
|
+
for resync_start_fn in self.event_strategy["resync_start"]:
|
|
555
|
+
await resync_start_fn()
|
|
556
|
+
|
|
553
557
|
try:
|
|
554
558
|
did_fetched_current_state = True
|
|
555
559
|
except httpx.HTTPError as e:
|
|
@@ -598,7 +602,7 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
|
|
|
598
602
|
if errors:
|
|
599
603
|
message = f"Resync failed with {len(errors)}. Skipping delete phase due to incomplete state"
|
|
600
604
|
error_group = ExceptionGroup(
|
|
601
|
-
|
|
605
|
+
message,
|
|
602
606
|
errors,
|
|
603
607
|
)
|
|
604
608
|
if not silent:
|
|
@@ -618,3 +622,12 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
|
|
|
618
622
|
)
|
|
619
623
|
|
|
620
624
|
logger.info("Resync finished successfully")
|
|
625
|
+
|
|
626
|
+
# Execute resync_complete hooks
|
|
627
|
+
if "resync_complete" in self.event_strategy:
|
|
628
|
+
logger.info("Executing resync_complete hooks")
|
|
629
|
+
|
|
630
|
+
for resync_complete_fn in self.event_strategy["resync_complete"]:
|
|
631
|
+
await resync_complete_fn()
|
|
632
|
+
|
|
633
|
+
logger.info("Finished executing resync_complete hooks")
|
port_ocean/core/ocean_types.py
CHANGED
|
@@ -19,6 +19,9 @@ LISTENER_RESULT = Awaitable[RAW_RESULT] | ASYNC_GENERATOR_RESYNC_TYPE
|
|
|
19
19
|
RESYNC_EVENT_LISTENER = Callable[[str], LISTENER_RESULT]
|
|
20
20
|
START_EVENT_LISTENER = Callable[[], Awaitable[None]]
|
|
21
21
|
|
|
22
|
+
BEFORE_RESYNC_EVENT_LISTENER = Callable[[], Awaitable[None]]
|
|
23
|
+
AFTER_RESYNC_EVENT_LISTENER = Callable[[], Awaitable[None]]
|
|
24
|
+
|
|
22
25
|
|
|
23
26
|
class RawEntityDiff(TypedDict):
|
|
24
27
|
before: list[RAW_ITEM]
|
|
@@ -44,3 +47,5 @@ class CalculationResult(NamedTuple):
|
|
|
44
47
|
class IntegrationEventsCallbacks(TypedDict):
|
|
45
48
|
start: list[START_EVENT_LISTENER]
|
|
46
49
|
resync: dict[str | None, list[RESYNC_EVENT_LISTENER]]
|
|
50
|
+
resync_start: list[BEFORE_RESYNC_EVENT_LISTENER]
|
|
51
|
+
resync_complete: list[AFTER_RESYNC_EVENT_LISTENER]
|
|
@@ -799,3 +799,177 @@ async def test_register_resource_raw_skip_event_type_http_request_upsert_called_
|
|
|
799
799
|
mock_sync_raw_mixin._calculate_raw.assert_called_once()
|
|
800
800
|
mock_sync_raw_mixin._map_entities_compared_with_port.assert_not_called()
|
|
801
801
|
mock_sync_raw_mixin.entities_state_applier.upsert.assert_called_once()
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
@pytest.mark.asyncio
|
|
805
|
+
async def test_on_resync_start_hooks_are_called(
|
|
806
|
+
mock_sync_raw_mixin: SyncRawMixin,
|
|
807
|
+
mock_port_app_config: PortAppConfig,
|
|
808
|
+
) -> None:
|
|
809
|
+
# Setup
|
|
810
|
+
resync_start_called = False
|
|
811
|
+
|
|
812
|
+
async def on_resync_start() -> None:
|
|
813
|
+
nonlocal resync_start_called
|
|
814
|
+
resync_start_called = True
|
|
815
|
+
|
|
816
|
+
mock_sync_raw_mixin.on_resync_start(on_resync_start)
|
|
817
|
+
|
|
818
|
+
# Execute
|
|
819
|
+
async with event_context(EventType.RESYNC, trigger_type="machine") as event:
|
|
820
|
+
event.port_app_config = mock_port_app_config
|
|
821
|
+
await mock_sync_raw_mixin.sync_raw_all(
|
|
822
|
+
trigger_type="machine",
|
|
823
|
+
user_agent_type=UserAgentType.exporter,
|
|
824
|
+
)
|
|
825
|
+
|
|
826
|
+
# Verify
|
|
827
|
+
assert resync_start_called, "on_resync_start hook was not called"
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
@pytest.mark.asyncio
|
|
831
|
+
async def test_on_resync_complete_hooks_are_called_on_success(
|
|
832
|
+
mock_sync_raw_mixin: SyncRawMixin,
|
|
833
|
+
mock_port_app_config: PortAppConfig,
|
|
834
|
+
mock_ocean: Ocean,
|
|
835
|
+
) -> None:
|
|
836
|
+
# Setup
|
|
837
|
+
resync_complete_called = False
|
|
838
|
+
|
|
839
|
+
async def on_resync_complete() -> None:
|
|
840
|
+
nonlocal resync_complete_called
|
|
841
|
+
resync_complete_called = True
|
|
842
|
+
|
|
843
|
+
mock_sync_raw_mixin.on_resync_complete(on_resync_complete)
|
|
844
|
+
mock_ocean.port_client.search_entities.return_value = [] # type: ignore
|
|
845
|
+
|
|
846
|
+
# Execute
|
|
847
|
+
async with event_context(EventType.RESYNC, trigger_type="machine") as event:
|
|
848
|
+
event.port_app_config = mock_port_app_config
|
|
849
|
+
await mock_sync_raw_mixin.sync_raw_all(
|
|
850
|
+
trigger_type="machine",
|
|
851
|
+
user_agent_type=UserAgentType.exporter,
|
|
852
|
+
)
|
|
853
|
+
|
|
854
|
+
# Verify
|
|
855
|
+
assert resync_complete_called, "on_resync_complete hook was not called"
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
@pytest.mark.asyncio
|
|
859
|
+
async def test_on_resync_complete_hooks_not_called_on_error(
|
|
860
|
+
mock_sync_raw_mixin: SyncRawMixin,
|
|
861
|
+
mock_port_app_config: PortAppConfig,
|
|
862
|
+
) -> None:
|
|
863
|
+
# Setup
|
|
864
|
+
resync_complete_called = False
|
|
865
|
+
|
|
866
|
+
async def on_resync_complete() -> None:
|
|
867
|
+
nonlocal resync_complete_called
|
|
868
|
+
resync_complete_called = True
|
|
869
|
+
|
|
870
|
+
mock_sync_raw_mixin.on_resync_complete(on_resync_complete)
|
|
871
|
+
mock_sync_raw_mixin._get_resource_raw_results.side_effect = Exception("Test error") # type: ignore
|
|
872
|
+
|
|
873
|
+
# Execute
|
|
874
|
+
async with event_context(EventType.RESYNC, trigger_type="machine") as event:
|
|
875
|
+
event.port_app_config = mock_port_app_config
|
|
876
|
+
with pytest.raises(Exception):
|
|
877
|
+
await mock_sync_raw_mixin.sync_raw_all(
|
|
878
|
+
trigger_type="machine",
|
|
879
|
+
user_agent_type=UserAgentType.exporter,
|
|
880
|
+
)
|
|
881
|
+
|
|
882
|
+
# Verify
|
|
883
|
+
assert (
|
|
884
|
+
not resync_complete_called
|
|
885
|
+
), "on_resync_complete hook should not have been called on error"
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
@pytest.mark.asyncio
|
|
889
|
+
async def test_multiple_on_resync_start_on_resync_complete_hooks_called_in_order(
|
|
890
|
+
mock_sync_raw_mixin: SyncRawMixin,
|
|
891
|
+
mock_port_app_config: PortAppConfig,
|
|
892
|
+
mock_ocean: Ocean,
|
|
893
|
+
) -> None:
|
|
894
|
+
# Setup
|
|
895
|
+
call_order: list[str] = []
|
|
896
|
+
|
|
897
|
+
async def on_resync_start1() -> None:
|
|
898
|
+
call_order.append("on_resync_start1")
|
|
899
|
+
|
|
900
|
+
async def on_resync_start2() -> None:
|
|
901
|
+
call_order.append("on_resync_start2")
|
|
902
|
+
|
|
903
|
+
async def on_resync_complete1() -> None:
|
|
904
|
+
call_order.append("on_resync_complete1")
|
|
905
|
+
|
|
906
|
+
async def on_resync_complete2() -> None:
|
|
907
|
+
call_order.append("on_resync_complete2")
|
|
908
|
+
|
|
909
|
+
mock_sync_raw_mixin.on_resync_start(on_resync_start1)
|
|
910
|
+
mock_sync_raw_mixin.on_resync_start(on_resync_start2)
|
|
911
|
+
mock_sync_raw_mixin.on_resync_complete(on_resync_complete1)
|
|
912
|
+
mock_sync_raw_mixin.on_resync_complete(on_resync_complete2)
|
|
913
|
+
mock_ocean.port_client.search_entities.return_value = [] # type: ignore
|
|
914
|
+
|
|
915
|
+
# Execute
|
|
916
|
+
async with event_context(EventType.RESYNC, trigger_type="machine") as event:
|
|
917
|
+
event.port_app_config = mock_port_app_config
|
|
918
|
+
await mock_sync_raw_mixin.sync_raw_all(
|
|
919
|
+
trigger_type="machine",
|
|
920
|
+
user_agent_type=UserAgentType.exporter,
|
|
921
|
+
)
|
|
922
|
+
|
|
923
|
+
# Verify
|
|
924
|
+
assert call_order == [
|
|
925
|
+
"on_resync_start1",
|
|
926
|
+
"on_resync_start2",
|
|
927
|
+
"on_resync_complete1",
|
|
928
|
+
"on_resync_complete2",
|
|
929
|
+
], "Hooks were not called in the correct order"
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
@pytest.mark.asyncio
|
|
933
|
+
async def test_on_resync_start_hook_error_prevents_resync(
|
|
934
|
+
mock_sync_raw_mixin: SyncRawMixin,
|
|
935
|
+
mock_port_app_config: PortAppConfig,
|
|
936
|
+
) -> None:
|
|
937
|
+
# Setup
|
|
938
|
+
resync_complete_called = False
|
|
939
|
+
resync_proceeded = False
|
|
940
|
+
|
|
941
|
+
async def on_resync_start() -> None:
|
|
942
|
+
raise Exception("Before resync error")
|
|
943
|
+
|
|
944
|
+
async def on_resync_complete() -> None:
|
|
945
|
+
nonlocal resync_complete_called
|
|
946
|
+
resync_complete_called = True
|
|
947
|
+
|
|
948
|
+
mock_sync_raw_mixin.on_resync_start(on_resync_start)
|
|
949
|
+
mock_sync_raw_mixin.on_resync_complete(on_resync_complete)
|
|
950
|
+
|
|
951
|
+
original_get_resource_raw_results = mock_sync_raw_mixin._get_resource_raw_results
|
|
952
|
+
|
|
953
|
+
async def track_resync(*args: Any, **kwargs: Any) -> Any:
|
|
954
|
+
nonlocal resync_proceeded
|
|
955
|
+
resync_proceeded = True
|
|
956
|
+
return await original_get_resource_raw_results(*args, **kwargs)
|
|
957
|
+
|
|
958
|
+
mock_sync_raw_mixin._get_resource_raw_results = track_resync # type: ignore
|
|
959
|
+
|
|
960
|
+
# Execute
|
|
961
|
+
async with event_context(EventType.RESYNC, trigger_type="machine") as event:
|
|
962
|
+
event.port_app_config = mock_port_app_config
|
|
963
|
+
with pytest.raises(Exception, match="Before resync error"):
|
|
964
|
+
await mock_sync_raw_mixin.sync_raw_all(
|
|
965
|
+
trigger_type="machine",
|
|
966
|
+
user_agent_type=UserAgentType.exporter,
|
|
967
|
+
)
|
|
968
|
+
|
|
969
|
+
# Verify
|
|
970
|
+
assert (
|
|
971
|
+
not resync_proceeded
|
|
972
|
+
), "Resync should not have proceeded after before_resync hook error"
|
|
973
|
+
assert (
|
|
974
|
+
not resync_complete_called
|
|
975
|
+
), "on_resync_complete hook should not have been called after error"
|
|
@@ -24,7 +24,7 @@ port_ocean/cli/commands/version.py,sha256=hEuIEIcm6Zkamz41Z9nxeSM_4g3oNlAgWwQyDG
|
|
|
24
24
|
port_ocean/cli/cookiecutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
port_ocean/cli/cookiecutter/cookiecutter.json,sha256=ie-LJjg-ek3lP2RRosY2u_q2W4y2TykXm_Gynjjt6Es,814
|
|
26
26
|
port_ocean/cli/cookiecutter/extensions.py,sha256=eQNjZvy2enDkJpvMbBGil77Xk9-38f862wfnmCjdoBc,446
|
|
27
|
-
port_ocean/cli/cookiecutter/hooks/post_gen_project.py,sha256=
|
|
27
|
+
port_ocean/cli/cookiecutter/hooks/post_gen_project.py,sha256=7DBdSv_vDI1YKW-y7y4wHenu4iF4zV1MukoUT1EgzXI,1182
|
|
28
28
|
port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.env.example,sha256=ywAmZto6YBGXyhEmpG1uYsgaHr2N1ZBRjdtRNt6Vkpw,388
|
|
29
29
|
port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.gitignore,sha256=32p1lDW_g5hyBz486GWfDeR9m7ikFlASVri5a8vmNoo,2698
|
|
30
30
|
port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.port/resources/.gitignore,sha256=kCpRPdl3S_jqYYZaOrc0-xa6-l3KqVjNRXc6jCkd_-Q,12
|
|
@@ -66,14 +66,14 @@ port_ocean/config/settings.py,sha256=PfMwhFQOI0zfK0bD32EunXqicVrlPYBkYC2A99nmZlg
|
|
|
66
66
|
port_ocean/consumers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
67
67
|
port_ocean/consumers/kafka_consumer.py,sha256=N8KocjBi9aR0BOPG8hgKovg-ns_ggpEjrSxqSqF_BSo,4710
|
|
68
68
|
port_ocean/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
69
|
-
port_ocean/context/event.py,sha256=
|
|
70
|
-
port_ocean/context/ocean.py,sha256=
|
|
69
|
+
port_ocean/context/event.py,sha256=pdLBnHl9Ue5Qyyxk_NLVnIizsj9rjFgAt5qzpXq-2yw,6492
|
|
70
|
+
port_ocean/context/ocean.py,sha256=Yt0KP3Rgc4MrLSo3dF0a40ww6ny0r2hDADZ42vTj22M,7750
|
|
71
71
|
port_ocean/context/resource.py,sha256=yDj63URzQelj8zJPh4BAzTtPhpKr9Gw9DRn7I_0mJ1s,1692
|
|
72
72
|
port_ocean/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
73
73
|
port_ocean/core/defaults/__init__.py,sha256=8qCZg8n06WAdMu9s_FiRtDYLGPGHbOuS60vapeUoAks,142
|
|
74
74
|
port_ocean/core/defaults/clean.py,sha256=_rL-NCl6Q_x3lUxDW5ACOM27IYilTCWl6ISUfRleuL0,2891
|
|
75
75
|
port_ocean/core/defaults/common.py,sha256=zJsj7jvlqIMLGXhdASUlbKS8GIAf-FDKKB0O7jB6nx0,4166
|
|
76
|
-
port_ocean/core/defaults/initialize.py,sha256=
|
|
76
|
+
port_ocean/core/defaults/initialize.py,sha256=wdc3UdhRTu_tRZuCnt9ZRtqbl4dSLa8u6E_dyiAuEWg,10980
|
|
77
77
|
port_ocean/core/event_listener/__init__.py,sha256=T3E52MKs79fNEW381p7zU9F2vOMvIiiTYWlqRUqnsg0,1135
|
|
78
78
|
port_ocean/core/event_listener/base.py,sha256=VdIdp7RLOSxH3ICyV-wCD3NiJoUzsh2KkJ0a9B29GeI,2847
|
|
79
79
|
port_ocean/core/event_listener/factory.py,sha256=M4Qi05pI840sjDIbdjUEgYe9Gp5ckoCkX-KgLBxUpZg,4096
|
|
@@ -109,14 +109,14 @@ port_ocean/core/handlers/webhook/webhook_event.py,sha256=Iuw6IX3PPjwHECUeFgrJl6K
|
|
|
109
109
|
port_ocean/core/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
110
110
|
port_ocean/core/integrations/base.py,sha256=eS0WDOfCTim1UOQQrNuP14I6hvT_fr8dof_cr1ls01s,3107
|
|
111
111
|
port_ocean/core/integrations/mixins/__init__.py,sha256=FA1FEKMM6P-L2_m7Q4L20mFa4_RgZnwSRmTCreKcBVM,220
|
|
112
|
-
port_ocean/core/integrations/mixins/events.py,sha256=
|
|
112
|
+
port_ocean/core/integrations/mixins/events.py,sha256=2L7P3Jhp8XBqddh2_o9Cn4N261nN1SySfrEdJoqLrIw,2714
|
|
113
113
|
port_ocean/core/integrations/mixins/handler.py,sha256=mZ7-0UlG3LcrwJttFbMe-R4xcOU2H_g33tZar7PwTv8,3771
|
|
114
114
|
port_ocean/core/integrations/mixins/live_events.py,sha256=8HklZmlyffYY_LeDe8xbt3Tb08rlLkqVhFF-2NQeJP4,4126
|
|
115
115
|
port_ocean/core/integrations/mixins/sync.py,sha256=GHiFbnw0XrBfl7aCTH_w67f_N7EZbcUgssc-0fPujNU,4047
|
|
116
|
-
port_ocean/core/integrations/mixins/sync_raw.py,sha256=
|
|
116
|
+
port_ocean/core/integrations/mixins/sync_raw.py,sha256=RzIQ7fawAeRR8g-ocZ_ChAE6PhZjcTHCq4iMd0T0y3Q,25316
|
|
117
117
|
port_ocean/core/integrations/mixins/utils.py,sha256=oN4Okz6xlaefpid1_Pud8HPSw9BwwjRohyNsknq-Myg,2309
|
|
118
118
|
port_ocean/core/models.py,sha256=FvTp-BlpbvLbMbngE0wsiimsCfmIhUR1PvsE__Z--1I,2206
|
|
119
|
-
port_ocean/core/ocean_types.py,sha256=
|
|
119
|
+
port_ocean/core/ocean_types.py,sha256=onwYMsvdd2_9QmZ7qU6h-t2uF_PTIivpEro0ahevhdw,1354
|
|
120
120
|
port_ocean/core/utils/entity_topological_sorter.py,sha256=MDUjM6OuDy4Xj68o-7InNN0w1jqjxeDfeY8U02vySNI,3081
|
|
121
121
|
port_ocean/core/utils/utils.py,sha256=HmumOeH27N0NX1_OP3t4oGKt074ht9XyXhvfZ5I05s4,6474
|
|
122
122
|
port_ocean/debug_cli.py,sha256=gHrv-Ey3cImKOcGZpjoHlo4pa_zfmyOl6TUM4o9VtcA,96
|
|
@@ -152,7 +152,7 @@ port_ocean/tests/core/defaults/test_common.py,sha256=sR7RqB3ZYV6Xn6NIg-c8k5K6JcG
|
|
|
152
152
|
port_ocean/tests/core/handlers/entities_state_applier/test_applier.py,sha256=R9bqyJocUWTh0NW0s-5ttD_SYYeM5EbYILgVmgWa7qA,2776
|
|
153
153
|
port_ocean/tests/core/handlers/entity_processor/test_jq_entity_processor.py,sha256=FnEnaDjuoAbKvKyv6xJ46n3j0ZcaT70Sg2zc7oy7HAA,13596
|
|
154
154
|
port_ocean/tests/core/handlers/mixins/test_live_events.py,sha256=iAwVpr3n3PIkXQLw7hxd-iB_SR_vyfletVXJLOmyz28,12480
|
|
155
|
-
port_ocean/tests/core/handlers/mixins/test_sync_raw.py,sha256=
|
|
155
|
+
port_ocean/tests/core/handlers/mixins/test_sync_raw.py,sha256=S1m6SQtlQVr3qD_otHEojj4pR87vICyO9ELNyAEwZRs,37428
|
|
156
156
|
port_ocean/tests/core/handlers/port_app_config/test_api.py,sha256=eJZ6SuFBLz71y4ca3DNqKag6d6HUjNJS0aqQPwiLMTI,1999
|
|
157
157
|
port_ocean/tests/core/handlers/port_app_config/test_base.py,sha256=tdjpFUnUZ6TNMxc3trKkzmMTGTb7oKIeu3rRXv_fV3g,6872
|
|
158
158
|
port_ocean/tests/core/handlers/queue/test_local_queue.py,sha256=9Ly0HzZXbs6Rbl_bstsIdInC3h2bgABU3roP9S_PnJM,2582
|
|
@@ -184,8 +184,8 @@ port_ocean/utils/repeat.py,sha256=U2OeCkHPWXmRTVoPV-VcJRlQhcYqPWI5NfmPlb1JIbc,32
|
|
|
184
184
|
port_ocean/utils/signal.py,sha256=mMVq-1Ab5YpNiqN4PkiyTGlV_G0wkUDMMjTZp5z3pb0,1514
|
|
185
185
|
port_ocean/utils/time.py,sha256=pufAOH5ZQI7gXvOvJoQXZXZJV-Dqktoj9Qp9eiRwmJ4,1939
|
|
186
186
|
port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
|
|
187
|
-
port_ocean-0.
|
|
188
|
-
port_ocean-0.
|
|
189
|
-
port_ocean-0.
|
|
190
|
-
port_ocean-0.
|
|
191
|
-
port_ocean-0.
|
|
187
|
+
port_ocean-0.21.1.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
188
|
+
port_ocean-0.21.1.dist-info/METADATA,sha256=C-0nf5tQjmGL6u0L3pKe7XpfOON72CXep4gh-FLXwp8,6669
|
|
189
|
+
port_ocean-0.21.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
190
|
+
port_ocean-0.21.1.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
|
|
191
|
+
port_ocean-0.21.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|