forked from singer-io/tap-appsflyer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added get_restricted_start_date function to restrict start_date to no…
… more than 90 days from current date. Added corresponding unittest. (singer-io#30) Co-authored-by: pbegle <[email protected]>
- Loading branch information
1 parent
014a281
commit 0dcfced
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import datetime | ||
from unittest.mock import patch | ||
|
||
from tap_appsflyer import get_restricted_start_date | ||
|
||
MOCKED_DATE = datetime.datetime(2021, 7, 1, 1, 1, 1, 369251) | ||
|
||
class MockedDatetime(datetime.datetime): | ||
def now(): | ||
return MOCKED_DATE | ||
|
||
@patch('datetime.datetime', MockedDatetime) | ||
def test_get_restricted_start_date(): | ||
test_cases = [ | ||
{'case': '2018-01-01T00:00:00Z', 'expected': datetime.datetime(2021, 4, 2, 1, 1, 1, 369251)}, | ||
{'case': '2021-07-27T00:00:00Z', 'expected': datetime.datetime(2021, 7, 27, 0, 0)}, | ||
{'case': '2021-04-02T00:00:00Z', 'expected': datetime.datetime(2021, 4, 2, 1, 1, 1, 369251)}, | ||
{'case': '2021-05-23T12:34:56Z', 'expected': datetime.datetime(2021, 5, 23, 12, 34, 56)}, | ||
] | ||
|
||
for test_case in test_cases: | ||
date = get_restricted_start_date(test_case['case']) | ||
|
||
assert date == test_case['expected'] |