示例#1
0
    def test_exception_raised_if_message_id_is_not_found(self):
        message = Message(
            connection=self.connection,
            collector_id=self.collector_id,
        )

        with HTTMock(self.mock.send):
            with pytest.raises(AttributeError):
                message.send()
示例#2
0
    def test_scheduled_date_correctly_formatted_for_post(self):
        message = Message(
            connection=self.connection,
            collector_id=self.collector_id,
            message_id=self.message_id,
        )
        message.post = MagicMock()

        with HTTMock(self.mock.send):
            message.send(scheduled_date=datetime.now() + timedelta(days=3))

        url = URL_MESSAGE_SEND.format(collector_id=self.collector_id,
                                      message_id=self.message_id)

        message.post.assert_called_with(
            base_url=url, data={'scheduled_date': '2015-10-09T12:56:55+00:00'})
示例#3
0
    def test_message_sent(self):
        message = Message(
            connection=self.connection,
            collector_id=self.collector_id,
            message_id=self.message_id,
        )

        with HTTMock(self.mock.send):
            response = message.send()

        expect(response).to(have_key("is_scheduled", True))