-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for SchedulerBase class methods
- Loading branch information
1 parent
95a46b8
commit 2910e90
Showing
1 changed file
with
51 additions
and
0 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,51 @@ | ||
import unittest | ||
from datetime import timedelta | ||
|
||
from rx.internal.constants import DELTA_ZERO, UTC_ZERO | ||
from rx.concurrency.schedulerbase import SchedulerBase | ||
|
||
|
||
class TestSchedulerBase(unittest.TestCase): | ||
|
||
def test_base_to_seconds(self): | ||
val = SchedulerBase.to_seconds(0.0) | ||
assert val == 0.0 | ||
val = SchedulerBase.to_seconds(DELTA_ZERO) | ||
assert val == 0.0 | ||
val = SchedulerBase.to_seconds(UTC_ZERO) | ||
assert val == 0.0 | ||
|
||
def test_base_to_datetime(self): | ||
val = SchedulerBase.to_datetime(0.0) | ||
assert val == UTC_ZERO | ||
val = SchedulerBase.to_datetime(DELTA_ZERO) | ||
assert val == UTC_ZERO | ||
val = SchedulerBase.to_datetime(UTC_ZERO) | ||
assert val == UTC_ZERO | ||
|
||
def test_base_to_timedelta(self): | ||
val = SchedulerBase.to_timedelta(0.0) | ||
assert val == DELTA_ZERO | ||
val = SchedulerBase.to_timedelta(DELTA_ZERO) | ||
assert val == DELTA_ZERO | ||
val = SchedulerBase.to_timedelta(UTC_ZERO) | ||
assert val == DELTA_ZERO | ||
|
||
def test_base_normalize_float(self): | ||
val = SchedulerBase.normalize(-1.0) | ||
assert val == 0.0 | ||
val = SchedulerBase.normalize(0.0) | ||
assert val == 0.0 | ||
val = SchedulerBase.normalize(1.0) | ||
assert val == 1.0 | ||
|
||
def test_base_normalize_delta(self): | ||
DELTA_ONE = timedelta(seconds=1.0) | ||
val = SchedulerBase.normalize(-DELTA_ONE) | ||
assert val == DELTA_ZERO | ||
val = SchedulerBase.normalize(DELTA_ZERO) | ||
assert val == DELTA_ZERO | ||
val = SchedulerBase.normalize(DELTA_ONE) | ||
assert val == DELTA_ONE | ||
|
||
|