def test_no_previous_frame(self, mocker): rsiv = RSIValueFactory() frame_mock = mocker.Mock() frame_mock.previous_frame = None rsiv.frame = frame_mock assert rsiv.extended_changes == []
def test_parent__call(self, mocker): parent_on_new_tick = mocker.patch( "estrade.graph.base_indicator.BaseIndicatorValue.on_new_tick" ) rsiv = RSIValueFactory() new_tick = TickFactory() rsiv.on_new_tick(new_tick, True) assert parent_on_new_tick.call_args_list == [call(new_tick, True)]
def test_value__nominal(self, mocker, extended_changes, expected_rsi): mocker.patch( "estrade.graph.indicators.rsi.RSIValue.extended_changes", new_callable=lambda: extended_changes, ) rsi = RSIFactory() rsi.rsi_periods = 4 rsiv = RSIValueFactory(indicator=rsi) assert rsiv.value == expected_rsi, rsiv._build_rs()
def test_previous_frame( self, mocker, last_tick_value, previous_frame_last_tick_value, expected ): rsiv = RSIValueFactory() frame_mock = mocker.Mock() frame_mock.last_tick.value = last_tick_value frame_mock.previous_frame.last_tick.value = previous_frame_last_tick_value rsiv.frame = frame_mock rsiv.last_changes = [1, 2] assert rsiv.extended_changes == expected
def test_last_changes__nominal(self, mocker): previous_mock = mocker.Mock() previous_mock.extended_changes = [1, 2, 3] mocker.patch( "estrade.graph.indicators.rsi.RSIValue.previous", new_callable=lambda: previous_mock, ) indicator = RSIFactory() indicator.rsi_periods = 3 rsiv = RSIValueFactory(indicator=indicator) assert rsiv.last_changes == [2, 3]
def test_last_changes__no_previous_indicator(self): rsiv = RSIValueFactory() assert rsiv.last_changes == []
def test_no_rsi_periods(self): rsi = RSIFactory() rsi.rsi_periods = None with pytest.raises(BaseIndicatorException): RSIValueFactory(indicator=rsi)