def test_get_latest_returns_latest_data_element_for_topic(self): C = DictConnection() topic_id = C.add_topic("topic", description="description", fields=["number"]) C.add_data(topic_id, {"number": 3}) C.add_data(topic_id, {"number": 2}) C.add_data(topic_id, {"number": 1}) latest = C.get_latest(topic_id) self.assertEqual(latest["number"], 1)
def test_get_latest_handles_empty_list(self): C = DictConnection() topic_id = C.add_topic("topic") with self.assertRaises(IndexError): C.get_latest(topic_id)