예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
 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'
예제 #4
0
 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"
예제 #5
0
 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()
예제 #7
0
 def test_attribute_error(self):
     with pytest.raises(AttributeError):
         Message(self.reddit, _data={'id': '1'}).mark_as_read()
예제 #8
0
 def test_str(self):
     message = Message(self.reddit, _data={'id': 'dummy'})
     assert str(message) == 'dummy'
예제 #9
0
 def test_repr(self):
     message = Message(self.reddit, _data={'id': 'dummy'})
     assert repr(message) == 'Message(id=\'dummy\')'
예제 #10
0
 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
예제 #11
0
 def test_fullname(self):
     message = Message(self.reddit, _data={'id': 'dummy'})
     assert message.fullname == 't4_dummy'
예제 #12
0
 def test_str(self):
     message = Message(self.reddit, _data={"id": "dummy"})
     assert str(message) == "dummy"
예제 #13
0
 def test_repr(self):
     message = Message(self.reddit, _data={"id": "dummy"})
     assert repr(message) == "Message(id='dummy')"
예제 #14
0
 def test_fullname(self):
     message = Message(self.reddit, _data={"id": "dummy"})
     assert message.fullname == "t4_dummy"