def test_schedule_campaign():
    """ schedules and unschedules a campaign """

    uid = md5.new(str(random.random())).hexdigest()
    subject = 'chimpy campaign schedule test %s' % uid
    options = {'list_id': list_id(),
           'subject': subject,
           'from_email': EMAIL_ADDRESS,
           'from_name': 'chimpy',
           'generate_text': True
           }

    html = """ <html><body><h1>My test newsletter</h1><p>Just testing</p>
               <a href="*|UNSUB|*">Unsubscribe</a>*|REWARDS|*</body>"""


    content = {'html': html}
    cid = chimp.campaign_create('regular', options, content)

    schedule_time = datetime.datetime(2012, 12, 20, 19, 0, 0)
    chimp.campaign_schedule(cid, schedule_time)

    campaign = chimp.campaigns(filter_subject=subject)['data'][0]
    assert campaign['status'] == 'schedule'
    assert campaign['send_time'] in ('Dec 20, 2012 07:00 pm', '2012-12-20 19:00:00')

    chimp.campaign_unschedule(cid)
    campaign = chimp.campaigns(filter_subject=subject)['data'][0]
    assert campaign['status'] == 'save'

    #clean up
    chimp.campaign_delete(cid)
dataset/ETHPy150Open divio/django-mailchimp/mailchimp/chimpy/test_chimpy.py/test_schedule_campaign/original