def test_previous_value_action_creator(self): result = db.previous_value("initial_time", "initial_times") expect = { "kind": "PREVIOUS_VALUE", "payload": { "item_key": "initial_time", "items_key": "initial_times" } } self.assertEqual(expect, result)
def test_previous_given_none_selects_earliest_time(self): action = db.previous_value("initial_time", "initial_times") state = {"initial_times": self.initial_times} store = redux.Store(db.reducer, initial_state=state, middlewares=[db.next_previous]) store.dispatch(action) result = store.state expect = { "initial_time": "2019-01-01 00:00:00", "initial_times": self.initial_times } self.assertEqual(expect, result)
def test_dimension_view_on_previous(): listener = unittest.mock.Mock() view = forest.db.control.DimensionView("item", "items") view.add_subscriber(listener) view.on_previous() listener.assert_called_once_with(db.previous_value("item", "items"))