-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scheduling future actions (#237)
* Fix scheduling future actions * add unit tests for sensor.utils datetime manipulations
- Loading branch information
1 parent
e02a8b1
commit 81d0653
Showing
2 changed files
with
24 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from datetime import datetime | ||
|
||
from django.conf import settings | ||
|
||
from sensor import utils | ||
|
||
|
||
def test_timestamp_manipulation(): | ||
now = datetime.now() | ||
now_int = int(now.timestamp()) | ||
now_fromint = datetime.fromtimestamp(now_int) | ||
now_str = now.strftime(settings.DATETIME_FORMAT) | ||
|
||
test_dt_int = utils.get_timestamp_from_datetime(now) | ||
test_dt_fromint = utils.get_datetime_from_timestamp(now_int) | ||
test_dt_fromstr = utils.parse_datetime_str(now_str) | ||
|
||
assert now_int == test_dt_int | ||
assert now_fromint == test_dt_fromint | ||
assert now == test_dt_fromstr |
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