Example #1
0
    def setUp(self):

        self.username = os.environ.get("ZOHO_USERNAME", None)
        self.password = os.environ.get("ZOHO_PASSWORD", None)
        self.authtoken = os.environ.get("ZOHO_AUTHTOKEN", None)

        if self.username and self.password and self.authtoken:
            # All ok
            pass
        else:
            raise RuntimeError(
                "Please set-up unit-test environment variables: ZOHO_USERNAME, ZOHO_PASSWORD and ZOHO_AUTHTOKEN to run tests"
            )

        # Initialize Zoho CRM api connection
        # You get necessary data from Zoho > Setup > Admin > Developer key
        self.crm = CRM(username=self.username,
                       password=self.password,
                       authtoken=self.authtoken,
                       scope="crmapi")

        # Open connection can be used to make as many as possible API calls
        self.crm.open()

        self.clear_test_leads()
Example #2
0
    def setUp(self):
        
        
        self.username = os.environ.get("ZOHO_USERNAME", None)
        self.password = os.environ.get("ZOHO_PASSWORD", None)
        self.authtoken = os.environ.get("ZOHO_AUTHTOKEN", None)
        
        if self.username and self.password and self.authtoken:
            # All ok
            pass
        else:
            raise RuntimeError("Please set-up unit-test environment variables: ZOHO_USERNAME, ZOHO_PASSWORD and ZOHO_AUTHTOKEN to run tests")

        # Initialize Zoho CRM api connection
        # You get necessary data from Zoho > Setup > Admin > Developer key
        self.crm = CRM(username=self.username, password=self.password, authtoken=self.authtoken, scope="crmapi")
        
        self.clear_test_leads()
Example #3
0
    def setUp(self):
        
        
        self.username = os.environ.get("ZOHO_USERNAME", None)
        self.password = os.environ.get("ZOHO_PASSWORD", None)
        self.apikey = os.environ.get("ZOHO_APIKEY", None)
        
        if self.username and self.password and self.apikey:
            # All ok
            pass
        else:
            raise RuntimeError("Please set-up unit-test environment variables: ZOHO_USERNAME, ZOHO_PASSWORD and ZOHO_APIKEY to run tests")

        # Initialize Zoho CRM api connection
        # You get necessary data from Zoho > Setup > Admin > Developer key
        self.crm = CRM(username=self.username, password=self.password, apikey=self.apikey)

        # Open connection can be used to make as many as possible API calls
        self.crm.open()
        
        self.clear_test_leads()
Example #4
0
from contact import Contact
from crm import CRM

our_crm_app = CRM()

# Original Python version:
# Contact.create('John', 'Smith', '*****@*****.**', 'John is a great guy!')
# Contact.create('Bit', 'Bot', '*****@*****.**', 'Loves Pokemon Go.')
# Contact.create('Betty', 'Maker', '*****@*****.**', 'beep boop')

# To populate Sqlite database:
# Contact.create(first_name='John', last_name='Smith', email='*****@*****.**', note='John is a great guy!')
# Contact.create(first_name='Bit', last_name='Bot', email='*****@*****.**', note='Loves Pokemon Go.')
# Contact.create(first_name='Betty', last_name='Maker', email='*****@*****.**', note='beep boop')

#CRM methods
our_crm_app.main_menu()

# our_crm_app.print_main_menu()

# our_crm_app.call_option(1)
# our_crm_app.call_option(2)
# our_crm_app.call_option(3)
# our_crm_app.call_option(4)
# our_crm_app.call_option(5)
# our_crm_app.call_option(6)
# our_crm_app.call_option(7)

# our_crm_app.add_new_contact()

# our_crm_app.modify_existing_contact()
Example #5
0
#!/usr/bin/env python
# coding: utf8
from crm import CRM

crm = CRM(authToken=authToken, scope="ZohoCRM/crmapi")

crm_insert = crm.insertRecords(module="CustomModule3",
                               xmlData=data,
                               version=2,
                               duplicateCheck=2)
Example #6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
from crm import CRM


crm = CRM(authToken=authToken,scope="ZohoCRM/crmapi")

crm_insert = crm.insertRecords(module="CustomModule3",
				xmlData=data,
				version=2,
				duplicateCheck=2)
Example #7
0
class TestCRM(unittest.TestCase):
    """ Zoho CRM specific tests. """

    def setUp(self):
        
        
        self.username = os.environ.get("ZOHO_USERNAME", None)
        self.password = os.environ.get("ZOHO_PASSWORD", None)
        self.authtoken = os.environ.get("ZOHO_AUTHTOKEN", None)
        
        if self.username and self.password and self.authtoken:
            # All ok
            pass
        else:
            raise RuntimeError("Please set-up unit-test environment variables: ZOHO_USERNAME, ZOHO_PASSWORD and ZOHO_AUTHTOKEN to run tests")

        # Initialize Zoho CRM api connection
        # You get necessary data from Zoho > Setup > Admin > Developer key
        self.crm = CRM(username=self.username, password=self.password, authtoken=self.authtoken, scope="crmapi")
        
        self.clear_test_leads()
        
    def tearDown(self):
        self.clear_test_leads()
        

    def add_dummy_lead(self):

        # Lead is just a bunch of dictionaried data
        # For possible lead parameters see crm.py.
        # Include non-ASCII characters.
        
        lead = {
            u"First Name" : u"TEST",
            u"Last Name" : u"UNIT TEST ÅÄÖ",
            u"Company" : u"mFabrik Research Oy"   
        }

        # Insert a new lead to Zoho CRM lead database.
        # We support multiple leads per call, so we need to listify our one lead first.
        self.crm.insert_leads([lead])
        
    def clear_test_leads(self):
        """ Remove all test leads from the database """
        
        records = self.crm.get_records()
        
        for record in records:
            if record["First Name"] == "TEST":
                self.crm.delete_record(record["LEADID"])
        
        
    def test_insert_lead(self):
        """ Sample insert lead scenario. """

        self.add_dummy_lead()

        
    def xxx_test_insert_duplicate(self):
        """ What happens when a duplicate lead is inserted """

        self.add_dummy_lead()
        self.add_dummy_lead()

        # TODO: Need to figure out how to force Zoho correctly detect duplicates
        
    def test_insert_missing_field(self):
        """ Company and Last name are required lead fields """

        
        lead = {
            "First Name" : "Who?"
        }

        try:
            self.crm.insert_leads([lead])
            raise AssertionError("Should not be reached")
        except ZohoException:
            pass
        
    def test_get_leads(self):

        # Make sure we have add least one lead there
        self.add_dummy_lead()
        
        leads = self.crm.get_records()
        print "Got leads"
        print leads
        
    def test_delete_leads(self):

        # Make sure we have add least one lead there
        self.add_dummy_lead()
        
        records = self.crm.get_records()
        
        # Count number of test items
        counter = 0
        for r in records:
            if r["First Name"] == "TEST":
                counter += 1
                
        self.assertEqual(counter, 1)
Example #8
0
class TestCRM(unittest.TestCase):
    """ Zoho CRM specific tests. """
    def setUp(self):

        self.username = os.environ.get("ZOHO_USERNAME", None)
        self.password = os.environ.get("ZOHO_PASSWORD", None)
        self.authtoken = os.environ.get("ZOHO_AUTHTOKEN", None)

        if self.username and self.password and self.authtoken:
            # All ok
            pass
        else:
            raise RuntimeError(
                "Please set-up unit-test environment variables: ZOHO_USERNAME, ZOHO_PASSWORD and ZOHO_AUTHTOKEN to run tests"
            )

        # Initialize Zoho CRM api connection
        # You get necessary data from Zoho > Setup > Admin > Developer key
        self.crm = CRM(username=self.username,
                       password=self.password,
                       authtoken=self.authtoken,
                       scope="crmapi")

        # Open connection can be used to make as many as possible API calls
        self.crm.open()

        self.clear_test_leads()

    def tearDown(self):
        self.clear_test_leads()

    def add_dummy_lead(self):

        # Lead is just a bunch of dictionaried data
        # For possible lead parameters see crm.py.
        # Include non-ASCII characters.

        lead = {
            u"First Name": u"TEST",
            u"Last Name": u"UNIT TEST ÅÄÖ",
            u"Company": u"mFabrik Research Oy"
        }

        # Insert a new lead to Zoho CRM lead database.
        # We support multiple leads per call, so we need to listify our one lead first.
        self.crm.insert_leads([lead])

    def clear_test_leads(self):
        """ Remove all test leads from the database """

        records = self.crm.get_records()

        for record in records:
            if record["First Name"] == "TEST":
                self.crm.delete_record(record["LEADID"])

    def test_insert_lead(self):
        """ Sample insert lead scenario. """

        self.add_dummy_lead()

    def xxx_test_insert_duplicate(self):
        """ What happens when a duplicate lead is inserted """

        self.add_dummy_lead()
        self.add_dummy_lead()

        # TODO: Need to figure out how to force Zoho correctly detect duplicates

    def test_insert_missing_field(self):
        """ Company and Last name are required lead fields """

        lead = {"First Name": "Who?"}

        try:
            self.crm.insert_leads([lead])
            raise AssertionError("Should not be reached")
        except ZohoException:
            pass

    def test_get_leads(self):

        # Make sure we have add least one lead there
        self.add_dummy_lead()

        leads = self.crm.get_records()
        print "Got leads"
        print leads

    def test_delete_leads(self):

        # Make sure we have add least one lead there
        self.add_dummy_lead()

        records = self.crm.get_records()

        # Count number of test items
        counter = 0
        for r in records:
            if r["First Name"] == "TEST":
                counter += 1

        self.assertEqual(counter, 1)
Example #9
0
fb_hr = pyrebase.initialize_app(config_HR)

# configs
crm_config = {
    "apiKey": "AIzaSyApbbE90LsWekODFSlRLDz4nOIegHajMSc",
    "authDomain": "cs490-e9fd5.firebaseapp.com",
    "databaseURL": "https://cs490-e9fd5.firebaseio.com",
    "projectId": "cs490-e9fd5",
    "storageBucket": "",
    "messagingSenderId": "1073025923441",
    "appId": "1:1073025923441:web:1e5196bf90ba1485"
}

# initialize CRM integration
crm_fb = CRM(crm_config)

# initlize model
model = Model('model')

#######################################################################################################################
'''
Tender Entry SCHEMA:
<Firebase_unique_key>:{
    "client_name":"Canadian Red Cross Society",
    "consultants":{
        "lead":"Bob Rossi",
        "member1":"Andrew Roberts"
    },
    "contact":{
        "email":"*****@*****.**",