def test_get_latest_state(self): State.create( state="TEAPOT_FULL", timestamp=datetime.now().isoformat(), num_of_cups=3 ) State.create( state="TEAPOT_EMPTY", timestamp=datetime.now() - timedelta(weeks=1), num_of_cups=0 ) result = State.get_newest_state() self.assertEqual(result.state, "TEAPOT_FULL") self.assertEqual(result.num_of_cups, 3)
def test_get_latest_state_none(self): result = State.get_newest_state() self.assertIsNone(result)