def test_replicate_update_campaign():
    """ replicates and updates a campaign """

    uid = md5.new(str(random.random())).hexdigest()
    subject = uid % 'chimpy campaign test %s'
    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)

    newcid = chimp.campaign_replicate(cid=cid)
    assert isinstance(newcid, basestring)

    newsubject = 'Fresh subject ' + uid
    newtitle = 'Custom title ' + uid

    res = chimp.campaign_update(newcid, 'subject', newsubject)
    assert res is True
    res = chimp.campaign_update(newcid, 'title', newtitle)
    assert res is True

#    campaigns = chimp.campaigns(filter_subject=newsubject)
#    pprint.pprint(campaigns['data'])
#    assert len(campaigns['data'])==1
#    campaigns = chimp.campaigns(filter_title=newtitle)
#    assert len(campaigns['data'])==1

    #clean up
    chimp.campaign_delete(newcid)
    chimp.campaign_delete(cid)
dataset/ETHPy150Open divio/django-mailchimp/mailchimp/chimpy/test_chimpy.py/test_replicate_update_campaign/swapped operands of `%`