Skip to content

Commit 8f2ab09

Browse files
authored
Source Dixa: add to connector index (#4701)
1 parent dbbab8f commit 8f2ab09

File tree

4 files changed

+28
-51
lines changed

4 files changed

+28
-51
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"sourceDefinitionId": "0b5c867e-1b12-4d02-ab74-97b2184ff6d7",
3+
"name": "Dixa",
4+
"dockerRepository": "airbyte/source-dixa",
5+
"dockerImageTag": "0.1.0",
6+
"documentationUrl": "https://docs.airbyte.io/integrations/sources/dixa"
7+
}

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,8 @@
368368
dockerRepository: airbyte/source-paypal-transaction
369369
dockerImageTag: 0.1.0
370370
documentationUrl: https://docs.airbyte.io/integrations/sources/paypal-transaction
371+
- sourceDefinitionId: 0b5c867e-1b12-4d02-ab74-97b2184ff6d7
372+
name: Dixa
373+
dockerRepository: airbyte/source-dixa
374+
dockerImageTag: 0.1.0
375+
documentationUrl: https://docs.airbyte.io/integrations/sources/dixa

airbyte-integrations/connectors/source-dixa/source_dixa/source.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ def ms_timestamp_to_datetime(milliseconds: int) -> datetime:
6060
"""
6161
Converts a millisecond-precision timestamp to a datetime object.
6262
"""
63-
return datetime.fromtimestamp(
64-
ConversationExport._validate_ms_timestamp(milliseconds) / 1000, tz=timezone.utc
65-
)
63+
return datetime.fromtimestamp(ConversationExport._validate_ms_timestamp(milliseconds) / 1000, tz=timezone.utc)
6664

6765
@staticmethod
6866
def datetime_to_ms_timestamp(dt: datetime) -> int:

airbyte-integrations/connectors/source-dixa/unit_tests/unit_test.py

+15-48
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
# SOFTWARE.
23+
#
24+
2325
from datetime import datetime, timezone
2426

2527
import pytest
@@ -28,9 +30,7 @@
2830

2931
@pytest.fixture
3032
def conversation_export():
31-
return ConversationExport(
32-
start_date=datetime(year=2021, month=7, day=1, hour=12, tzinfo=timezone.utc), batch_size=1, logger=None
33-
)
33+
return ConversationExport(start_date=datetime(year=2021, month=7, day=1, hour=12, tzinfo=timezone.utc), batch_size=1, logger=None)
3434

3535

3636
def test_validate_ms_timestamp_with_valid_input():
@@ -49,28 +49,14 @@ def test_validate_ms_timestamp_with_invalid_input_length():
4949

5050
def test_ms_timestamp_to_datetime():
5151
assert ConversationExport.ms_timestamp_to_datetime(1625312980123) == datetime(
52-
year=2021,
53-
month=7,
54-
day=3,
55-
hour=11,
56-
minute=49,
57-
second=40,
58-
microsecond=123000,
59-
tzinfo=timezone.utc
52+
year=2021, month=7, day=3, hour=11, minute=49, second=40, microsecond=123000, tzinfo=timezone.utc
6053
)
6154

6255

6356
def test_datetime_to_ms_timestamp():
6457
assert (
65-
ConversationExport.datetime_to_ms_timestamp(datetime(
66-
year=2021,
67-
month=7,
68-
day=3,
69-
hour=11,
70-
minute=49,
71-
second=40,
72-
microsecond=123000,
73-
tzinfo=timezone.utc)
58+
ConversationExport.datetime_to_ms_timestamp(
59+
datetime(year=2021, month=7, day=3, hour=11, minute=49, second=40, microsecond=123000, tzinfo=timezone.utc)
7460
)
7561
== 1625312980123
7662
)
@@ -83,14 +69,8 @@ def test_add_days_to_ms_timestamp():
8369
def test_stream_slices_without_state(conversation_export):
8470
conversation_export.end_timestamp = 1625270400001 # 2021-07-03 00:00:00 + 1 ms
8571
expected_slices = [
86-
{
87-
'updated_after': 1625140800000, # 2021-07-01 12:00:00
88-
'updated_before': 1625227200000 # 2021-07-02 12:00:00
89-
},
90-
{
91-
'updated_after': 1625227200000,
92-
'updated_before': 1625270400001
93-
}
72+
{"updated_after": 1625140800000, "updated_before": 1625227200000}, # 2021-07-01 12:00:00 # 2021-07-02 12:00:00
73+
{"updated_after": 1625227200000, "updated_before": 1625270400001},
9474
]
9575
actual_slices = conversation_export.stream_slices()
9676
assert actual_slices == expected_slices
@@ -101,12 +81,7 @@ def test_stream_slices_without_state_large_batch():
10181
start_date=datetime(year=2021, month=7, day=1, hour=12, tzinfo=timezone.utc), batch_size=31, logger=None
10282
)
10383
conversation_export.end_timestamp = 1625270400001 # 2021-07-03 00:00:00 + 1 ms
104-
expected_slices = [
105-
{
106-
'updated_after': 1625140800000, # 2021-07-01 12:00:00
107-
'updated_before': 1625270400001
108-
}
109-
]
84+
expected_slices = [{"updated_after": 1625140800000, "updated_before": 1625270400001}] # 2021-07-01 12:00:00
11085
actual_slices = conversation_export.stream_slices()
11186
assert actual_slices == expected_slices
11287

@@ -123,26 +98,18 @@ def test_stream_slices_with_start_timestamp_larger_than_state():
12398
Test that if start_timestamp is larger than state, then start at start_timestamp.
12499
"""
125100
conversation_export = ConversationExport(
126-
start_date=datetime(year=2021, month=12, day=1, tzinfo=timezone.utc), batch_size=31,
127-
logger=None
101+
start_date=datetime(year=2021, month=12, day=1, tzinfo=timezone.utc), batch_size=31, logger=None
128102
)
129103
conversation_export.end_timestamp = 1638360000001 # 2021-12-01 12:00:00 + 1 ms
130-
expected_slices = [
131-
{
132-
'updated_after': 1638316800000, # 2021-07-01 12:00:00
133-
'updated_before': 1638360000001
134-
}
135-
]
136-
actual_slices = conversation_export.stream_slices(
137-
stream_state={'updated_at': 1625220000000} # # 2021-07-02 12:00:00
138-
)
104+
expected_slices = [{"updated_after": 1638316800000, "updated_before": 1638360000001}] # 2021-07-01 12:00:00
105+
actual_slices = conversation_export.stream_slices(stream_state={"updated_at": 1625220000000}) # # 2021-07-02 12:00:00
139106
assert actual_slices == expected_slices
140107

141108

142109
def test_get_updated_state_without_state(conversation_export):
143-
assert conversation_export.get_updated_state(
144-
current_stream_state=None, latest_record={'updated_at': 1625263200000}
145-
) == {'updated_at': 1625140800000}
110+
assert conversation_export.get_updated_state(current_stream_state=None, latest_record={"updated_at": 1625263200000}) == {
111+
"updated_at": 1625140800000
112+
}
146113

147114

148115
def test_get_updated_state_with_bigger_state(conversation_export):

0 commit comments

Comments
 (0)