'Test renewal notification functionality for curators'

@patch('mozillians.groups.tasks.send_mail')
@patch('mozillians.groups.tasks.now')
def test_send_renewal_notification_curators_email(self, mock_now, mock_send_mail):

    curator1 = UserFactory.create(email='foo@example.com')
    curator2 = UserFactory.create(email='foobar@example.com')
    member = UserFactory.create(userprofile={'full_name': 'Example    Name'})
    group = GroupFactory.create(name='foobar', invalidation_days=365, accepting_new_members=Group.REVIEWED)
    group.curators.add(curator1.userprofile)
    group.curators.add(curator2.userprofile)
    group.add_member(member.userprofile)
    datetime_now = (now() + timedelta(days=351))
    mock_now.return_value = datetime_now
    notify_membership_renewal()
    ok_(mock_send_mail.called)
    eq_(3, len(mock_send_mail.mock_calls))
    (name, args, kwargs) = mock_send_mail.mock_calls[1]
    (subject, body, from_addr, to_list) = args
    eq_(subject, '[Mozillians][foobar]    Membership    of    "Example    Name"    is    about    to    expire')
    eq_(from_addr, settings.FROM_NOREPLY)
    eq_(list(to_list), [u'foo@example.com'])
    (name, args, kwargs) = mock_send_mail.mock_calls[2]
    (subject, body, from_addr, to_list) = args
    eq_(subject, '[Mozillians][foobar]    Membership    of    "Example    Name"    is    about    to    expire')
    eq_(from_addr, settings.FROM_NOREPLY)
    eq_(list(to_list), [u'foobar@example.com'])
