def test_hash(self): message1 = Message(self.reddit, _data={'id': 'dummy1'}) message2 = Message(self.reddit, _data={'id': 'dummy1'}) message3 = Message(self.reddit, _data={'id': 'dummy2'}) assert hash(message1) == hash(message1) assert hash(message2) == hash(message2) assert hash(message3) == hash(message3) assert hash(message1) == hash(message2) assert hash(message2) != hash(message3) assert hash(message1) != hash(message3)
def test_hash(self): message1 = Message(self.reddit, _data={"id": "dummy1"}) message2 = Message(self.reddit, _data={"id": "dummy1"}) message3 = Message(self.reddit, _data={"id": "dummy2"}) assert hash(message1) == hash(message1) assert hash(message2) == hash(message2) assert hash(message3) == hash(message3) assert hash(message1) == hash(message2) assert hash(message2) != hash(message3) assert hash(message1) != hash(message3)
def test_equality(self): message1 = Message(self.reddit, _data={'id': '1'}) message2 = Message(self.reddit, _data={'id': '1'}) message3 = Message(self.reddit, _data={'id': '2'}) assert message1 == message1 assert message2 == message2 assert message3 == message3 assert message1 == message2 assert message2 != message3 assert message1 != message3 assert '1' == message1 assert message1 == '1'
def test_equality(self): message1 = Message(self.reddit, _data={"id": "1"}) message2 = Message(self.reddit, _data={"id": "1"}) message3 = Message(self.reddit, _data={"id": "2"}) assert message1 == message1 assert message2 == message2 assert message3 == message3 assert message1 == message2 assert message2 != message3 assert message1 != message3 assert "1" == message1 assert message1 == "1"
def reply_to_private_message(self, message: Message, body: Text) -> NoReturn: log.debug('Replying to private message from %s with subject %s', message.dest.name, message.subject) try: message.reply(body) self._save_private_message( BotPrivateMessage(subject=message.subject, body=body, triggered_from='inbox_reply', recipient=message.dest.name)) except RedditAPIException: log.exception('Problem replying to private message', exc_info=True)
def test_check_for_new_invites_no_invite(self): Message = namedtuple('Message', ['subject']) m = Message('invitation to moderate') reddit = Mock(inbox=Mock(messages=PropertyMock(return_value=[m]))) with mock.patch.object(NewActivationMonitor, 'activate_sub') as mocked_monitor: monitor = NewActivationMonitor(MagicMock(), reddit=reddit) monitor.check_for_new_invites() mocked_monitor.assert_called()
def test_attribute_error(self): with pytest.raises(AttributeError): Message(self.reddit, _data={'id': '1'}).mark_as_read()
def test_str(self): message = Message(self.reddit, _data={'id': 'dummy'}) assert str(message) == 'dummy'
def test_repr(self): message = Message(self.reddit, _data={'id': 'dummy'}) assert repr(message) == 'Message(id=\'dummy\')'
def test_pickle(self): message = Message(self.reddit, _data={'id': 'dummy'}) for level in range(pickle.HIGHEST_PROTOCOL + 1): other = pickle.loads(pickle.dumps(message, protocol=level)) assert message == other
def test_fullname(self): message = Message(self.reddit, _data={'id': 'dummy'}) assert message.fullname == 't4_dummy'
def test_str(self): message = Message(self.reddit, _data={"id": "dummy"}) assert str(message) == "dummy"
def test_repr(self): message = Message(self.reddit, _data={"id": "dummy"}) assert repr(message) == "Message(id='dummy')"
def test_fullname(self): message = Message(self.reddit, _data={"id": "dummy"}) assert message.fullname == "t4_dummy"