コード例 #1
0
def test_get_rows_does_no_error_checking_of_rows_or_cells(mocker):
    has_error_mock = mocker.patch.object(Row, 'has_error')
    has_bad_recipient_mock = mocker.patch.object(Row, 'has_bad_recipient')
    has_missing_data_mock = mocker.patch.object(Row, 'has_missing_data')
    cell_recipient_error_mock = mocker.patch.object(Cell, 'recipient_error')

    recipients = RecipientCSV("""
            email address, name
            [email protected],
            [email protected], My Name
            [email protected],


        """,
                              template_type='email',
                              placeholders=['name'],
                              max_errors_shown=3)

    rows = recipients.get_rows()
    for i in range(3):
        assert next(rows).recipient == '*****@*****.**'

    assert has_error_mock.called is False
    assert has_bad_recipient_mock.called is False
    assert has_missing_data_mock.called is False
    assert cell_recipient_error_mock.called is False
コード例 #2
0
def test_get_rows_only_iterates_over_file_once(mocker):
    row_mock = mocker.patch('notifications_utils.recipients.Row')

    recipients = RecipientCSV(
        """
            email address, name
            [email protected],
            [email protected], My Name
            [email protected],


        """,
        template=_sample_template('email', 'hello ((name))'),
    )

    rows = recipients.get_rows()
    for i in range(3):
        next(rows)

    assert row_mock.call_count == 3
    assert recipients.rows_as_list is None