def test_updating_timestamp_will_make_message_rearrange_in_conversation(self, mock_sort): message = Message( "memento mori", datetime(2011, 3, 1, 12, 34, 32), self.contact1 ) message._conversation = Mock(Conversation) message._conversation._messages = [message] message.timestamp(datetime(2012, 1, 19, 9, 23, 56)) mock_sort.assert_called_with([message])
def test_new_timestamp_must_be_datetime(self): message = Message( "memento mori", datetime(2011, 3, 1, 12, 34, 32), self.contact1 ) with self.assertRaises(TypeError): message.timestamp(1000) with self.assertRaises(TypeError): message.timestamp(datetime(2012, 1, 19, 9, 23, 56).date())
def test_can_update_message_timestamp(self): message = Message( "memento mori", datetime(2011, 3, 1, 12, 34, 32), self.contact1 ) message.timestamp(datetime(2012, 1, 19, 9, 23, 56)) self.assertEqual(message._timestamp, datetime(2012, 1, 19, 9, 23, 56))
def test_message_timestamp(self): message = Message( "memento mori", datetime(2011, 3, 1, 12, 34, 32), self.contact1 ) self.assertIs(message._timestamp, message.timestamp())