def test_import_proposal_sheets(self): context = utils.ImportContext(subsidiary=self.subsidiary) firm_lst = utils.load_objects(os.path.join(TEST_DIR, 'proposals'), 'firms') utils.import_firms(firm_lst) contact_lst = utils.load_objects(os.path.join(TEST_DIR, 'proposals'), 'contacts') utils.import_contacts(contact_lst) proposal_sheet_lst = utils.load_objects(os.path.join(TEST_DIR, 'proposals'), 'proposal_sheets') utils.import_proposal_sheets(proposal_sheet_lst, context) # Check lead 3, linked to a firm lead = Lead.objects.get(external_id="incwo:3") self.assertEquals(lead.state, 'WON') self.assertEquals(lead.deal_id, 'D1234-56789') self.assertEquals(lead.name, 'Project Foobar') self.assertEquals(lead.description, 'Echo Alpha Tango') client = Client.objects.get(organisation__company__external_id="incwo:1", contact=None) self.assertEquals(lead.client, client) # Check lead 4, linked to a contact lead = Lead.objects.get(external_id="incwo:4") self.assertEquals(lead.state, 'WON') self.assertEquals(lead.deal_id, 'D5678-90123') self.assertEquals(lead.name, 'No Firm ID Proposal') client = Client.objects.get(contact__external_id="incwo:12") self.assertEquals(lead.client, client) # No lead 5, because it was lost self.assertFalse(Lead.objects.filter(external_id="incwo:5"))
def test_import_proposal_sheets(self): context = utils.ImportContext(subsidiary=self.subsidiary) firm_lst = utils.load_objects(os.path.join(TEST_DIR, "proposals"), "firms") utils.import_firms(firm_lst) contact_lst = utils.load_objects(os.path.join(TEST_DIR, "proposals"), "contacts") utils.import_contacts(contact_lst) proposal_sheet_lst = utils.load_objects(os.path.join(TEST_DIR, "proposals"), "proposal_sheets") utils.import_proposal_sheets(proposal_sheet_lst, context) # Check lead 3, linked to a firm lead = Lead.objects.get(external_id="incwo:3") self.assertEquals(lead.state, "WON") self.assertEquals(lead.deal_id, "D1234-56789") self.assertEquals(lead.name, "Project Foobar") self.assertEquals(lead.description, "Echo Alpha Tango") client = Client.objects.get(organisation__company__external_id="incwo:1", contact=None) self.assertEquals(lead.client, client) # Check lead 4, linked to a contact lead = Lead.objects.get(external_id="incwo:4") self.assertEquals(lead.state, "WON") self.assertEquals(lead.deal_id, "D5678-90123") self.assertEquals(lead.name, "No Firm ID Proposal") client = Client.objects.get(contact__external_id="incwo:12") self.assertEquals(lead.client, client) # No lead 5, because it was lost self.assertFalse(Lead.objects.filter(external_id="incwo:5"))
def test_import_homonyms(self): lst = utils.load_objects(os.path.join(TEST_DIR, 'homonyms'), 'firms') utils.import_firms(lst) lst = utils.load_objects(os.path.join(TEST_DIR, 'homonyms'), 'contacts') utils.import_contacts(lst) contact_lst = Contact.objects.filter(name='John Doe') self.assertEquals(len(contact_lst), 2)
def test_import_homonyms(self): lst = utils.load_objects(os.path.join(TEST_DIR, "homonyms"), "firms") utils.import_firms(lst) lst = utils.load_objects(os.path.join(TEST_DIR, "homonyms"), "contacts") utils.import_contacts(lst) contact_lst = Contact.objects.filter(name="John Doe") self.assertEquals(len(contact_lst), 2)
def test_import_contact_items(self): contact_lst = utils.load_objects(os.path.join(TEST_DIR, 'contact-items'), '.') utils.import_contacts(contact_lst) contact = Contact.objects.get(external_id="incwo:12") self.assertEquals(contact.email, '*****@*****.**') self.assertEquals(contact.phone, '01 23 45 67 89') self.assertEquals(contact.mobile_phone, '06 78 90 12 34') self.assertEquals(contact.fax, '01 23 45 67 01')
def test_import_contact_items(self): contact_lst = utils.load_objects(os.path.join(TEST_DIR, "contact-items"), ".") utils.import_contacts(contact_lst) contact = Contact.objects.get(external_id="incwo:12") self.assertEquals(contact.email, "*****@*****.**") self.assertEquals(contact.phone, "01 23 45 67 89") self.assertEquals(contact.mobile_phone, "06 78 90 12 34") self.assertEquals(contact.fax, "01 23 45 67 01")
def test_import_contact(self): firm_lst = utils.load_objects(os.path.join(TEST_DIR, 'contacts'), 'firms') utils.import_firms(firm_lst) contact_lst = utils.load_objects(os.path.join(TEST_DIR, 'contacts'), 'contacts') utils.import_contacts(contact_lst) company = Company.objects.get(pk=1) classic_contact = Contact.objects.get(external_id="incwo:12") jobless_contact = Contact.objects.get(external_id="incwo:34") company_contacts = Contact.objects.filter(client__organisation__company=company) self.assertItemsEqual(company_contacts, [classic_contact, jobless_contact]) # Import twice to check for conflicts utils.import_firms(firm_lst) utils.import_contacts(contact_lst)
def test_import_contact(self): firm_lst = utils.load_objects(os.path.join(TEST_DIR, "contacts"), "firms") utils.import_firms(firm_lst) contact_lst = utils.load_objects(os.path.join(TEST_DIR, "contacts"), "contacts") utils.import_contacts(contact_lst) company = Company.objects.get(pk=1) classic_contact = Contact.objects.get(external_id="incwo:12") jobless_contact = Contact.objects.get(external_id="incwo:34") company_contacts = Contact.objects.filter(client__organisation__company=company) self.assertItemsEqual(company_contacts, [classic_contact, jobless_contact]) # Import twice to check for conflicts utils.import_firms(firm_lst) utils.import_contacts(contact_lst)