Пример #1
0
    def test_exception_raised_when_recipient_has_empty_email(self, recipients):
        message = Message(
            connection=self.connection,
            collector_id=self.collector_id,
            message_id=self.message_id,
        )

        with HTTMock(self.mock.recipient_add):
            with pytest.raises(ValueError):
                message.recipients(recipients)
Пример #2
0
    def test_exception_raised_when_no_message_id_is_provided_and_message_is_not_newly_created(
            self, recipients):  # noqa:E501
        message = Message(
            connection=self.connection,
            collector_id=self.collector_id,
        )

        with HTTMock(self.mock.recipient_add):
            with pytest.raises(AttributeError):
                message.recipients(recipients)
Пример #3
0
    def test_exception_raised_when_recipient_dictionary_is_missing_email_key(
            self, recipients):
        message = Message(
            connection=self.connection,
            collector_id=self.collector_id,
            message_id=self.message_id,
        )

        with HTTMock(self.mock.recipient_add):
            with pytest.raises(KeyError):
                message.recipients(recipients)
Пример #4
0
    def test_exception_raised_when_recipient_has_empty_extra_field(
            self, recipients):
        message = Message(
            connection=self.connection,
            collector_id=self.collector_id,
            message_id=self.message_id,
        )

        with HTTMock(self.mock.recipient_add):
            with pytest.raises(ValueError):
                message.recipients(
                    recipients, extra_field_mapping={'some_field': 'some_key'})
Пример #5
0
    def test_exception_raised_when_recipient_dictionary_is_missing_custom_field_key(
            self, recipients):
        message = Message(
            connection=self.connection,
            collector_id=self.collector_id,
            message_id=self.message_id,
        )

        with HTTMock(self.mock.recipient_add):
            with pytest.raises(KeyError):
                message.recipients(recipients,
                                   custom_field_mapping={'1': 'name'})
Пример #6
0
    def test_add_recipients_to_existing_message(self, recipients):
        message = Message(
            connection=self.connection,
            collector_id=self.collector_id,
            message_id=self.message_id,
        )

        with HTTMock(self.mock.recipient_add):
            response = message.recipients(recipients)

        expect(response["succeeded"]).to(have_length(be_above_or_equal(1)))
Пример #7
0
    def test_create_new_message_and_add_a_recipients(self, recipients):
        message = Message(connection=self.connection,
                          collector_id=self.collector_id,
                          config=self.config)

        with HTTMock(MessagesMock(self.config).create):
            message.create()

        with HTTMock(self.mock.recipient_add):
            response = message.recipients(recipients)

        expect(response["succeeded"]).to(have_length(be_above_or_equal(1)))