<s> import unittest <EOL> from createsend import * <EOL> class ClientTestCase ( object ) : <EOL> def test_create ( self ) : <EOL> c = Client ( ) <EOL> c . stub_request ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> client_id = c . create ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEquals ( "<STR_LIT>" , client_id ) <EOL> self . assertEquals ( "<STR_LIT>" , c . client_id ) <EOL> def test_details ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , "<STR_LIT>" ) <EOL> cl = self . cl . details ( ) <EOL> self . assertEquals ( cl . ApiKey , "<STR_LIT>" ) <EOL> self . assertEquals ( cl . BasicDetails . ClientID , "<STR_LIT>" ) <EOL> self . assertEquals ( cl . BasicDetails . ContactName , "<STR_LIT>" ) <EOL> self . assertEquals ( cl . AccessDetails . Username , "<STR_LIT>" ) <EOL> self . assertEquals ( cl . AccessDetails . AccessLevel , <NUM_LIT> ) <EOL> self . assertEquals ( cl . BillingDetails . Credits , <NUM_LIT> ) <EOL> def test_campaigns ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , "<STR_LIT>" ) <EOL> campaigns = self . cl . campaigns ( ) <EOL> self . assertEquals ( len ( campaigns ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . CampaignID , '<STR_LIT>' ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . WebVersionURL , '<STR_LIT>' ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . WebVersionTextURL , '<STR_LIT>' ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . Subject , '<STR_LIT>' ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . Name , '<STR_LIT>' ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . SentDate , '<STR_LIT>' ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . TotalRecipients , <NUM_LIT> ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . FromName , '<STR_LIT>' ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . FromEmail , '<STR_LIT>' ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . ReplyTo , '<STR_LIT>' ) <EOL> def test_scheduled ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , "<STR_LIT>" ) <EOL> campaigns = self . cl . scheduled ( ) <EOL> self . assertEquals ( len ( campaigns ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . DateScheduled , "<STR_LIT>" ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . ScheduledTimeZone , "<STR_LIT>" ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . CampaignID , "<STR_LIT>" ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . Name , "<STR_LIT>" ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . Subject , "<STR_LIT>" ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . DateCreated , "<STR_LIT>" ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . PreviewURL , "<STR_LIT>" ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . PreviewTextURL , "<STR_LIT>" ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . FromName , '<STR_LIT>' ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . FromEmail , '<STR_LIT>' ) <EOL> self . assertEquals ( campaigns [ <NUM_LIT:0> ] . ReplyTo , '<STR_LIT>' ) <EOL> def test_drafts ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , "<STR_LIT>" ) <EOL> drafts = self . cl . drafts ( ) <EOL> self . assertEquals ( len ( drafts ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( drafts [ <NUM_LIT:0> ] . CampaignID , '<STR_LIT>' ) <EOL> self . assertEquals ( drafts [ <NUM_LIT:0> ] . Name , '<STR_LIT>' ) <EOL> self . assertEquals ( drafts [ <NUM_LIT:0> ] . Subject , '<STR_LIT>' ) <EOL> self . assertEquals ( drafts [ <NUM_LIT:0> ] . DateCreated , '<STR_LIT>' ) <EOL> self . assertEquals ( drafts [ <NUM_LIT:0> ] . PreviewURL , '<STR_LIT>' ) <EOL> self . assertEquals ( drafts [ <NUM_LIT:0> ] . PreviewTextURL , '<STR_LIT>' ) <EOL> self . assertEquals ( drafts [ <NUM_LIT:0> ] . FromName , '<STR_LIT>' ) <EOL> self . assertEquals ( drafts [ <NUM_LIT:0> ] . FromEmail , '<STR_LIT>' ) <EOL> self . assertEquals ( drafts [ <NUM_LIT:0> ] . ReplyTo , '<STR_LIT>' ) <EOL> def test_lists ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , "<STR_LIT>" ) <EOL> lists = self . cl . lists ( ) <EOL> self . assertEquals ( len ( lists ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( lists [ <NUM_LIT:0> ] . ListID , '<STR_LIT>' ) <EOL> self . assertEquals ( lists [ <NUM_LIT:0> ] . Name , '<STR_LIT>' ) <EOL> def test_lists_for_email ( self ) : <EOL> email = "<STR_LIT>" <EOL> self . cl . stub_request ( "<STR_LIT>" % ( self . cl . client_id , urllib . quote ( email ) ) , "<STR_LIT>" ) <EOL> lists = self . cl . lists_for_email ( email ) <EOL> self . assertEquals ( len ( lists ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( lists [ <NUM_LIT:0> ] . ListID , '<STR_LIT>' ) <EOL> self . assertEquals ( lists [ <NUM_LIT:0> ] . ListName , '<STR_LIT>' ) <EOL> self . assertEquals ( lists [ <NUM_LIT:0> ] . SubscriberState , '<STR_LIT>' ) <EOL> self . assertEquals ( lists [ <NUM_LIT:0> ] . DateSubscriberAdded , '<STR_LIT>' ) <EOL> def test_segments ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , "<STR_LIT>" ) <EOL> segments = self . cl . segments ( ) <EOL> self . assertEquals ( len ( segments ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( segments [ <NUM_LIT:0> ] . ListID , '<STR_LIT>' ) <EOL> self . assertEquals ( segments [ <NUM_LIT:0> ] . SegmentID , '<STR_LIT>' ) <EOL> self . assertEquals ( segments [ <NUM_LIT:0> ] . Title , '<STR_LIT>' ) <EOL> def test_suppressionlist ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , "<STR_LIT>" ) <EOL> res = self . cl . suppressionlist ( ) <EOL> self . assertEquals ( res . ResultsOrderedBy , "<STR_LIT:email>" ) <EOL> self . assertEquals ( res . OrderDirection , "<STR_LIT>" ) <EOL> self . assertEquals ( res . PageNumber , <NUM_LIT:1> ) <EOL> self . assertEquals ( res . PageSize , <NUM_LIT:1000> ) <EOL> self . assertEquals ( res . RecordsOnThisPage , <NUM_LIT:5> ) <EOL> self . assertEquals ( res . TotalNumberOfRecords , <NUM_LIT:5> ) <EOL> self . assertEquals ( res . NumberOfPages , <NUM_LIT:1> ) <EOL> self . assertEquals ( len ( res . Results ) , <NUM_LIT:5> ) <EOL> self . assertEquals ( res . Results [ <NUM_LIT:0> ] . SuppressionReason , "<STR_LIT>" ) <EOL> self . assertEquals ( res . Results [ <NUM_LIT:0> ] . EmailAddress , "<STR_LIT>" ) <EOL> self . assertEquals ( res . Results [ <NUM_LIT:0> ] . Date , "<STR_LIT>" ) <EOL> self . assertEquals ( res . Results [ <NUM_LIT:0> ] . State , "<STR_LIT>" ) <EOL> def test_suppress_with_single_email ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , None ) <EOL> self . cl . suppress ( "<STR_LIT>" ) <EOL> def test_suppress_with_multiple_emails ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , None ) <EOL> self . cl . suppress ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def test_unsuppress ( self ) : <EOL> email = "<STR_LIT>" <EOL> self . cl . stub_request ( "<STR_LIT>" % ( self . cl . client_id , urllib . quote ( email ) ) , None ) <EOL> res = self . cl . unsuppress ( email ) <EOL> def test_templates ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , "<STR_LIT>" ) <EOL> templates = self . cl . templates ( ) <EOL> self . assertEquals ( len ( templates ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( templates [ <NUM_LIT:0> ] . TemplateID , '<STR_LIT>' ) <EOL> self . assertEquals ( templates [ <NUM_LIT:0> ] . Name , '<STR_LIT>' ) <EOL> def test_set_basics ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , None ) <EOL> self . cl . set_basics ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_set_payg_billing ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , None ) <EOL> self . cl . set_payg_billing ( "<STR_LIT>" , True , True , <NUM_LIT> ) <EOL> def test_set_monthly_billing_implicit ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , None , None , "<STR_LIT>" ) <EOL> self . cl . set_monthly_billing ( "<STR_LIT>" , True , <NUM_LIT> ) <EOL> def test_set_monthly_billing_basic ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , None , None , "<STR_LIT>" ) <EOL> self . cl . set_monthly_billing ( "<STR_LIT>" , False , <NUM_LIT> , "<STR_LIT>" ) <EOL> def test_set_monthly_billing_unlimited ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , None , None , "<STR_LIT>" ) <EOL> self . cl . set_monthly_billing ( "<STR_LIT>" , True , <NUM_LIT:100> , "<STR_LIT>" ) <EOL> def test_transfer_credits ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , "<STR_LIT>" ) <EOL> result = self . cl . transfer_credits ( <NUM_LIT:200> , False ) <EOL> self . assertEquals ( result . AccountCredits , <NUM_LIT> ) <EOL> self . assertEquals ( result . ClientCredits , <NUM_LIT:200> ) <EOL> def test_people ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , "<STR_LIT>" ) <EOL> people = self . cl . people ( ) <EOL> self . assertEquals ( <NUM_LIT:2> , len ( people ) ) <EOL> self . assertEquals ( '<STR_LIT>' , people [ <NUM_LIT:0> ] . EmailAddress ) <EOL> self . assertEquals ( '<STR_LIT>' , people [ <NUM_LIT:0> ] . Name ) <EOL> self . assertEquals ( '<STR_LIT>' , people [ <NUM_LIT:0> ] . Status ) <EOL> def test_get_primary_contact ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , "<STR_LIT>" ) <EOL> primary_contact = self . cl . get_primary_contact ( ) <EOL> self . assertEquals ( '<STR_LIT>' , primary_contact . EmailAddress ) <EOL> def test_set_primary_contact ( self ) : <EOL> email = '<STR_LIT>' <EOL> self . cl . stub_request ( "<STR_LIT>" % ( self . cl . client_id , urllib . quote ( email , '<STR_LIT>' ) ) , '<STR_LIT>' ) <EOL> result = self . cl . set_primary_contact ( email ) <EOL> self . assertEquals ( email , result . EmailAddress ) <EOL> def test_delete ( self ) : <EOL> self . cl . stub_request ( "<STR_LIT>" % self . cl . client_id , None ) <EOL> self . cl . delete ( ) <EOL> class OAuthClientTestCase ( unittest . TestCase , ClientTestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . cl = Client ( <EOL> { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } , "<STR_LIT>" ) <EOL> class ApiKeyClientTestCase ( unittest . TestCase , ClientTestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . cl = Client ( <EOL> { '<STR_LIT>' : '<STR_LIT>' } , "<STR_LIT>" ) </s>
