-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2697eff
commit 7fa8519
Showing
4 changed files
with
50 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ dependencies: | |
- tox==4.11.4 | ||
- netcdf4==1.6.5 | ||
- syrupy==4.6.1 | ||
- freezegun==1.5.1 | ||
- pip: | ||
- pytest-order==1.2.1 |
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
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,31 @@ | ||
from datetime import datetime | ||
|
||
from freezegun import freeze_time | ||
|
||
from copernicusmarine.core_functions.utils import datetime_parser | ||
|
||
|
||
class TestUtilityFunctions: | ||
@freeze_time("2012-01-14 03:21:34", tz_offset=-2) | ||
def test_datetime_parser(self): | ||
# all parsed dates are in UTC | ||
assert datetime_parser("now") == datetime(2012, 1, 14, 1, 21, 34) | ||
assert datetime_parser("2012-01-14T03:21:34.000000+02:00") == datetime( | ||
2012, 1, 14, 1, 21, 34 | ||
) | ||
|
||
# All format are supported | ||
assert datetime_parser("2012") == datetime(2012, 1, 1, 0, 0, 0) | ||
assert datetime_parser("2012-01-14") == datetime(2012, 1, 14, 0, 0, 0) | ||
assert datetime_parser("2012-01-14T03:21:34") == datetime( | ||
2012, 1, 14, 3, 21, 34 | ||
) | ||
assert datetime_parser("2012-01-14 03:21:34") == datetime( | ||
2012, 1, 14, 3, 21, 34 | ||
) | ||
assert datetime_parser("2012-01-14T03:21:34.000000") == datetime( | ||
2012, 1, 14, 3, 21, 34 | ||
) | ||
assert datetime_parser("2012-01-14T03:21:34.000000Z") == datetime( | ||
2012, 1, 14, 3, 21, 34 | ||
) |