Skip to content

Commit

Permalink
Add unit tests for new field date_ranges_end_date
Browse files Browse the repository at this point in the history
  • Loading branch information
CapCaWork committed Dec 20, 2024
1 parent e07ef8e commit a3d61ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def stream_slices(
else:
start_date = self.config["date_ranges_start_date"]

end_date = min(self.config.get("date_ranges_end_date"), today)
end_date = min(self.config.get("date_ranges_end_date", today), today)

while start_date <= end_date:
# stop producing slices if 429 + specific scenario is hit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"\"The custom report daily_active_users entered contains invalid dimensions: {'name': 'city'} is not of type 'string'. Validate your custom query with the GA 4 Query Explorer (https://ga-dev-tools.google/ga4/query-explorer/).\"",
),
({"date_ranges_start_date": "2022-20-20"}, Status.FAILED, "\"time data '2022-20-20' does not match format '%Y-%m-%d'\""),
({"date_ranges_end_date": "2022-20-20"}, Status.FAILED, "\"time data '2022-20-20' does not match format '%Y-%m-%d'\""),
(
{"credentials": {"auth_type": "Service", "credentials_json": "invalid"}},
Status.FAILED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ def test_stream_slices():
{"startDate": "2022-12-30", "endDate": "2023-01-01"},
]

config = {"date_ranges_start_date": datetime.date(2022, 12, 20), "date_ranges_end_date": datetime.date(2022, 12, 26), "window_in_days": 5, "dimensions": ["date"]}
stream = GoogleAnalyticsDataApiBaseStream(authenticator=None, config=config)
slices = list(stream.stream_slices(sync_mode=None))
assert slices == [
{"startDate": "2022-12-20", "endDate": "2022-12-24"},
{"startDate": "2022-12-25", "endDate": "2022-12-26"},
]

@freeze_time("2023-01-01 00:00:00")
def test_full_refresh():
"""
Expand Down

0 comments on commit a3d61ce

Please sign in to comment.