Exemplo n.º 1
0
    def test_cont_email_address(self):
        contact = Contact()
        email_address = Email_Address()

        email_address.set_email_address("*****@*****.**")

        self.assertEqual(contact.get_email_address(), None)

        contact.set_email_address(email_address)

        self.assertEqual(contact.get_email_address().get_email_address(), "*****@*****.**")
Exemplo n.º 2
0
def cc_indiegogo_signup(request):
    if request.method == "POST":
        constantcontact = ConstantContact(settings.CONSTANT_CONTACT_API_KEY, settings.CONSTANT_CONTACT_ACCESS_TOKEN, settings.CONSTANT_CONTACT_API_URL)
        contact = Contact()
        contact.add_list_id(settings.CONSTANT_CONTACT_LIST_ID)
        contact.set_email_address(request.POST['email'])
        response = constantcontact.post_contacts(contact)

        if response.has_key('error_key'):
            return HttpResponse(response['error_key'])
        else:
            return HttpResponse('201')
    def test_cont_notes(self):
        contact = Contact()

        self.assertEqual(contact.get_notes(), None)

        contact.set_note('Weakness: leafblowers')

        self.assertEqual(contact.get_notes()[0]['note'],
                         'Weakness: leafblowers')

        contact.clear_notes()

        self.assertEqual(contact.get_notes(), None)
Exemplo n.º 4
0
    def test_cont_notes(self):
        contact = Contact()

        self.assertEqual(contact.get_notes(), None)

        contact.set_note("Weakness: leafblowers")

        self.assertEqual(contact.get_notes()[0]["note"], "Weakness: leafblowers")

        contact.clear_notes()

        self.assertEqual(contact.get_notes(), None)
Exemplo n.º 5
0
    def test_event_contact(self):
        event = Event()

        contact = Contact()

        contact.set_prefix_name("Prof.")
        contact.set_last_name("Oak")

        event.set_contact(contact)

        self.assertEqual(event.get_contact()["name"], "Prof. Oak")

        account_info = Account_Info()

        account_info.set_first_name("Gary")
        account_info.set_last_name("Oak")

        event.set_contact(account_info)

        self.assertEqual(event.get_contact()["name"], "Gary Oak")

        event.delete_contact()

        self.assertEqual(event.get_contact(), None)
    def test_cont_email_address(self):
        contact = Contact()
        email_address = Email_Address()

        email_address.set_email_address('*****@*****.**')

        self.assertEqual(contact.get_email_address(), None)

        contact.set_email_address(email_address)

        self.assertEqual(contact.get_email_address().get_email_address(),
                         '*****@*****.**')
Exemplo n.º 7
0
def cc_indiegogo_signup(request):
    if request.method == "POST":
        constantcontact = ConstantContact(
            settings.CONSTANT_CONTACT_API_KEY,
            settings.CONSTANT_CONTACT_ACCESS_TOKEN,
            settings.CONSTANT_CONTACT_API_URL)
        contact = Contact()
        contact.add_list_id(settings.CONSTANT_CONTACT_LIST_ID)
        contact.set_email_address(request.POST['email'])
        response = constantcontact.post_contacts(contact)

        if response.has_key('error_key'):
            return HttpResponse(response['error_key'])
        else:
            return HttpResponse('201')
Exemplo n.º 8
0
    def test_event_contact(self):
        event = Event()

        contact = Contact()

        contact.set_prefix_name('Prof.')
        contact.set_last_name('Oak')

        event.set_contact(contact)

        self.assertEqual(event.get_contact()['name'], 'Prof. Oak')

        account_info = Account_Info()

        account_info.set_first_name('Gary')
        account_info.set_last_name('Oak')

        event.set_contact(account_info)

        self.assertEqual(event.get_contact()['name'], 'Gary Oak')

        event.delete_contact()

        self.assertEqual(event.get_contact(), None)
    def test_cont_custom_field(self):
        contact = Contact()

        contact.set_custom_field(2, 'Really likes sweaters')
        contact.set_custom_field(3, 'Bill was here')
        contact.set_custom_field(14, 'Has a pig named Waddles')

        self.assertEqual(contact.get_custom_field(0), None)
        self.assertEqual(contact.get_custom_field(1), None)
        self.assertEqual(
            contact.get_custom_field(2)['value'], 'Really likes sweaters')
        self.assertEqual(
            contact.get_custom_field(14)['value'], 'Has a pig named Waddles')

        contact.remove_custom_field(3)

        self.assertEqual(
            contact.get_custom_field('2')['value'], 'Really likes sweaters')
        self.assertEqual(contact.get_custom_field(3), None)

        contact.clear_custom_fields()

        self.assertEqual(contact.get_custom_field(2), None)
Exemplo n.º 10
0
    def test_cont_init_from_dict(self):
        contact = Contact({'first_name': 'Dipper', 'last_name': 'Pines'})

        self.assertEqual(contact.get_first_name(), 'Dipper')
Exemplo n.º 11
0
    def test_cont_address(self):
        contact = Contact()
        address = Address()

        address.set_state('Oregon')
        address.set_city('Gravity Falls')
        address.set_address_type('BUSINESS')

        self.assertEqual(contact.get_addresses(), None)

        contact.set_address(address)

        self.assertEqual(
            contact.get_address('BUSINESS').get_city(), 'Gravity Falls')

        contact.remove_address('PERSONAL')

        self.assertEqual(
            contact.get_address('BUSINESS').get_city(), 'Gravity Falls')

        contact.clear_addresses()

        self.assertEqual(contact.get_address('BUSINESS'), None)
Exemplo n.º 12
0
    def test_cont_setter_getter(self):
        contact = Contact()

        contact.set_first_name("Mabel")
        contact.set_last_name("Pines")
        contact.set_company_name("The Mystery hack")

        self.assertEqual(contact.get_job_title(), None)
        self.assertEqual(contact.get_first_name(), "Mabel")
        self.assertEqual(contact.get_last_name(), "Pines")

        contact.delete_last_name()

        self.assertEqual(contact.get_last_name(), None)
Exemplo n.º 13
0
    def test_cont_address(self):
        contact = Contact()
        address = Address()

        address.set_state("Oregon")
        address.set_city("Gravity Falls")
        address.set_address_type("BUSINESS")

        self.assertEqual(contact.get_addresses(), None)

        contact.set_address(address)

        self.assertEqual(contact.get_address("BUSINESS").get_city(), "Gravity Falls")

        contact.remove_address("PERSONAL")

        self.assertEqual(contact.get_address("BUSINESS").get_city(), "Gravity Falls")

        contact.clear_addresses()

        self.assertEqual(contact.get_address("BUSINESS"), None)
Exemplo n.º 14
0
    def test_cont_setter_getter(self):
        contact = Contact()

        contact.set_first_name('Mabel')
        contact.set_last_name('Pines')
        contact.set_company_name('The Mystery hack')

        self.assertEqual(contact.get_job_title(), None)
        self.assertEqual(contact.get_first_name(), 'Mabel')
        self.assertEqual(contact.get_last_name(), 'Pines')

        contact.delete_last_name()

        self.assertEqual(contact.get_last_name(), None)
Exemplo n.º 15
0
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

print '[test] get_events'
response = constantcontact.get_events(limit = 3)
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

start_date = (datetime.now() + timedelta(hours=6)).replace(minute=0)
end_date = (datetime.now() + timedelta(days=5)).replace(minute=0)

verified_email_address = constantcontact.get_verified_email_addresses('CONFIRMED')[0]['email_address']

contact = Contact()
contact.set_email_address(verified_email_address)
contact.set_first_name('Bob')
contact.set_company_name('Justice League')
contact.set_work_phone('8675309')

event = Event()
event.set_end_date(end_date.isoformat())
event.set_name('Test event '+str(randint(1000000, 9999999)))
event.set_title('please ignore')
event.set_contact(contact)
event.set_location('THE SECRET MOONBASE')
event.set_time_zone_id('US/Eastern')
event.set_type('OTHER')
event.set_start_date(start_date.isoformat())
Exemplo n.º 16
0
    def test_cont_init_from_dict(self):
        contact = Contact({"first_name": "Dipper", "last_name": "Pines"})

        self.assertEqual(contact.get_first_name(), "Dipper")
Exemplo n.º 17
0
    def test_cont_lists(self):
        contact = Contact()

        lists = [{'id': '123'}, {'id': '456'}, {'id': '789'}]
        contact_list = Contact_List({'id': '321'})

        contact.set_lists(lists)

        self.assertEqual(len(contact.get_lists()), 3)
        self.assertEqual(contact.get_list(2).get_id(), '789')

        contact.add_list(contact_list)
        contact.add_list_id('654')
        contact.remove_list_id('123')
        contact.remove_list(1)

        self.assertEqual(contact.get_list(0).get_id(), '456')
        self.assertEqual(contact.get_list(2).get_id(), '654')
        self.assertEqual(len(contact.get_lists()), 3)

        contact.remove_all_lists()

        self.assertEqual(contact.get_lists(), None)
Exemplo n.º 18
0
    def test_cont_custom_field(self):
        contact = Contact()

        contact.set_custom_field(2, "Really likes sweaters")
        contact.set_custom_field(3, "Bill was here")
        contact.set_custom_field(14, "Has a pig named Waddles")

        self.assertEqual(contact.get_custom_field(0), None)
        self.assertEqual(contact.get_custom_field(1), None)
        self.assertEqual(contact.get_custom_field(2)["value"], "Really likes sweaters")
        self.assertEqual(contact.get_custom_field(14)["value"], "Has a pig named Waddles")

        contact.remove_custom_field(3)

        self.assertEqual(contact.get_custom_field("2")["value"], "Really likes sweaters")
        self.assertEqual(contact.get_custom_field(3), None)

        contact.clear_custom_fields()

        self.assertEqual(contact.get_custom_field(2), None)
Exemplo n.º 19
0
    def test_cont_lists(self):
        contact = Contact()

        lists = [{"id": "123"}, {"id": "456"}, {"id": "789"}]
        contact_list = Contact_List({"id": "321"})

        contact.set_lists(lists)

        self.assertEqual(len(contact.get_lists()), 3)
        self.assertEqual(contact.get_list(2).get_id(), "789")

        contact.add_list(contact_list)
        contact.add_list_id("654")
        contact.remove_list_id("123")
        contact.remove_list(1)

        self.assertEqual(contact.get_list(0).get_id(), "456")
        self.assertEqual(contact.get_list(2).get_id(), "654")
        self.assertEqual(len(contact.get_lists()), 3)

        contact.remove_all_lists()

        self.assertEqual(contact.get_lists(), None)
Exemplo n.º 20
0
print '[test] get_next_page'
response = constantcontact.next_page(next_page)
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

contact_lists = constantcontact.get_lists()

for l in contact_lists:
    if l.get_name().lower() == 'general interest':
        list_id = l.get_id()
        break

print '[test] post_contacts'
contact = Contact()
contact.add_list_id(list_id)
contact.add_list_id('1481737116')
contact.set_email_address(test_email)
response = constantcontact.post_contacts(contact)
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

print '[test] get_contact by email'
response = constantcontact.get_contacts(email = test_email)
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')
contact = response['results'][0]
contact_id = contact.get_id()
Exemplo n.º 21
0
from constantcontact import ConstantContact, Contact, Multipart_Activity

import json
    
from random import randint

printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

contact1 = Contact()
contact1.set_email_address('*****@*****.**')
contact1.set_first_name('Albus')

contact2 = Contact()
contact2.set_email_address('*****@*****.**')
contact2.set_first_name('Severus')

import_data = []
import_data.append(contact1)
import_data.append(contact2)

contact_lists = constantcontact.get_lists()

for l in contact_lists:
    if l.get_name().lower() == 'general interest':