def test_edit_random_post_text(self, mock_get_post): media = Media("", ContentType.TEXT) mock_get_post.return_value = Post("", "", "", "", media) mock_msg = Mock() mock_msg.text = "" mock_msg.caption = None self.linker.edit_random_post(mock_msg, "r/test")
def test_edit_random_post_types(self, mock_type, mock_get_post): media = Media("", mock_type) mock_get_post.return_value = Post("", "", "", "", media) mock_msg = Mock() mock_msg.text = None mock_msg.caption = "" mock_msg.caption_markdown = "" self.linker.edit_random_post(mock_msg, "r/test")
def test_edit_random_post_youtube(self, mock_get_post): media = Media("", ContentType.YOUTUBE) mock_get_post.return_value = Post("", "", "", "", media) mock_msg = Mock() mock_msg.text = "" mock_msg.caption = None mock_msg.caption_markdown = "" self.linker.edit_random_post(mock_msg, "r/test")
def test_edit_random_post_invalid(self, mock_get_post): media = Media("", ContentType.TEXT) mock_get_post.return_value = Post("", "", "", "", media) mock_msg = Mock() mock_msg.text = None mock_msg.caption = "" with self.assertRaises(PostEqualsMessageError): self.linker.edit_random_post(mock_msg, "r/test")
def test_send_post_media_too_big(self, mock_get_post): media = Media("", ContentType.PHOTO, size=MAX_MEDIA_SIZE + 1) mock_get_post.return_value = Post("", "", "", "", media) with self.assertRaises(TeleredditError): self.linker.send_post("")
def test_send_post_from_url_true(self, mock_get_post): media = Media("", ContentType.PHOTO) mock_get_post.return_value = Post("", "", "", "", media) self.linker.send_post("", from_url=True)
def test_send_post_no_type(self, mock_get_post): media = Media("", None) mock_get_post.return_value = Post("", "", "", "", media) self.linker.send_post("")
def test_send_post(self, mock_content_type, mock_get_post): media = Media("", mock_content_type) mock_get_post.return_value = Post("", "", "", "", media) self.linker.send_post("")
def test_send_post_err(self, mock_get_post, mock_send_message): mock_send_message.side_effect = TeleredditError("") media = Media("", ContentType.TEXT) mock_get_post.return_value = Post("", "", "", "", media) with self.assertRaises(TeleredditError): self.linker.send_post("")