Skip to content

Commit

Permalink
Add unit tests for SchedulerBase class methods
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkemperman committed Apr 29, 2019
1 parent 95a46b8 commit 2910e90
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/test_concurrency/test_schedulerbase.py
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


0 comments on commit 2910e90

Please sign in to comment.