Skip to content

Commit

Permalink
Source Amplitude: add unit test for updated state (#30934)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-yermilov-gl committed Sep 29, 2023
1 parent 64edf61 commit af85501
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,25 @@ def test_event_request_params(self):
)
params = stream.request_params(stream_slice={"start": "20230801T00", "end": "20230801T23"})
assert params == {"start": "20230801T00", "end": "20230801T23"}

def test_updated_state(self):
stream = Events(
authenticator=MagicMock(),
start_date="2023-08-01T00:00:00Z",
data_region="Standard Server",
event_time_interval={"size_unit": "hours", "size": 24},
)

# Sample is in unordered state on purpose. We need to ensure state allways keeps latest value
cursor_fields_smaple = [
{"server_upload_time": "2023-08-29"},
{"server_upload_time": "2023-08-28"},
{"server_upload_time": "2023-08-31"},
{"server_upload_time": "2023-08-30"},
]

state = {"server_upload_time": "2023-01-01"}
for record in cursor_fields_smaple:
state = stream.get_updated_state(state, record)

assert state["server_upload_time"] == "2023-08-31 00:00:00.000000"

0 comments on commit af85501

Please sign in to comment.