def test_seconds(self, input_datetime, unit_quantity, expected_start): tf = TimeframeMixin(unit=Unit.SECOND, unit_quantity=unit_quantity) assert tf.get_frame_start( arrow.get(input_datetime)) == arrow.get(expected_start)
def test_nominal(self, unit, unit_quantity): with pytest.raises(TimeFrameException): TimeframeMixin(unit=unit, unit_quantity=unit_quantity)
def test_tick(self): tf = TimeframeMixin(unit=Unit.TICK, unit_quantity=3) now = arrow.utcnow() assert tf.get_frame_start(now) == now
def test_days(self, input_datetime, unit_quantity, expected_end): tf = TimeframeMixin(unit=Unit.DAY, unit_quantity=unit_quantity) timeframe_end = tf.get_frame_end(arrow.get(input_datetime)) assert timeframe_end == arrow.get(expected_end)
def test_unit_quantity(self): tf = TimeframeMixin(unit=Unit.SECOND, unit_quantity=4) assert tf.unit_quantity == 4
def test_tick(self): tf = TimeframeMixin(unit=Unit.TICK, unit_quantity=1) input_dt = arrow.utcnow() timeframe_end = tf.get_frame_end(input_dt) assert timeframe_end == input_dt
def test_unit(self, unit): tf = TimeframeMixin(unit=unit, unit_quantity=1) assert tf.unit == unit
def test_month(self, input_datetime, unit_quantity, expected_start): tf = TimeframeMixin(unit=Unit.MONTH, unit_quantity=unit_quantity) assert tf.get_frame_start( arrow.get(input_datetime)) == arrow.get(expected_start)