

@mock.patch('website.mailchimp_utils.get_mailchimp_api')
def test_get_list_id_from_name(self, mock_get_mailchimp_api):
    list_name = 'foo'
    mock_client = mock.MagicMock()
    mock_get_mailchimp_api.return_value = mock_client
    mock_client.lists.list.return_value = {
        'data': [{
            'id': 1,
            'list_name': list_name,
        }],
    }
    list_id = mailchimp_utils.get_list_id_from_name(list_name)
    mock_client.lists.list.assert_called_with(filters={
        'list_name': list_name,
    })
    assert_equal(list_id, 1)

dataset/ETHPy150Open CenterForOpenScience/osf.io/tests/test_mailchimp.py TestMailChimpHelpers.test_get_list_id_from_name/original