Esempio n. 1
0
    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"))
Esempio n. 2
0
    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"))
Esempio n. 3
0
 def test_import_firms_twice(self):
     lst = utils.load_objects(os.path.join(TEST_DIR, 'import-twice'), '.')
     nb_objects = len(lst)
     utils.import_firms(lst)
     self.assertEquals(len(Company.objects.all()), nb_objects)
     utils.import_firms(lst)
     self.assertEquals(len(Company.objects.all()), nb_objects)
Esempio n. 4
0
 def test_import_firms_twice(self):
     lst = utils.load_objects(os.path.join(TEST_DIR, "import-twice"), ".")
     nb_objects = len(lst)
     utils.import_firms(lst)
     self.assertEquals(len(Company.objects.all()), nb_objects)
     utils.import_firms(lst)
     self.assertEquals(len(Company.objects.all()), nb_objects)
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
Esempio n. 7
0
    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)
Esempio n. 8
0
    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)
Esempio n. 9
0
 def test_duplicate_firms(self):
     lst = utils.load_objects(os.path.join(TEST_DIR, 'duplicate-firms'), '.')
     nb_objects = len(lst)
     utils.import_firms(lst)
     self.assertEquals(len(Company.objects.all()), nb_objects)
Esempio n. 10
0
 def test_duplicate_firms(self):
     lst = utils.load_objects(os.path.join(TEST_DIR, "duplicate-firms"), ".")
     nb_objects = len(lst)
     utils.import_firms(lst)
     self.assertEquals(len(Company.objects.all()), nb_objects)