コード例 #1
0
    def test_lead_task_create(self):
        lead = BaseLead(name='test', status='test1')
        lead.save()

        complete_date = datetime.now() + timedelta(days=3)
        task = LeadTask(lead=lead,
                        text='test task text',
                        type='Call',
                        complete_till=complete_date)
        self.assertEqual(task.lead.name, 'test')
        self.assertEqual(task.lead.id, lead.id)
        self.assertEqual(task.text, 'test task text')
        self.assertEqual(task.complete_till.date(), complete_date.date())

        task.save()
        self.assertEqual(task.lead.name, 'test')
        self.assertEqual(task.lead.id, lead.id)
        self.assertEqual(task.text, 'test task text')
        self.assertEqual(task.complete_till.date(), complete_date.date())

        _task = LeadTask.objects.get(task.id)
        self.assertEqual(_task.lead.name, 'test')
        self.assertEqual(_task.lead.id, lead.id)
        self.assertEqual(_task.text, 'test task text')
        self.assertEqual(_task._element_type, LeadTask._ELEMENT_TYPES['lead'])
        self.assertEqual(_task.complete_till.date(), complete_date.date())
コード例 #2
0
contact_search = Contact.objects.search('Example2')
assert contact.id == contact_search.id
print(contact.phone)
contact.phone = '8-800-00000000'
contact.save()
contact.create_task('New task, yeee',
                    task_type='Звонок',
                    complete_till=datetime.datetime.now() +
                    datetime.timedelta(days=3))
print(contact.notes)
print(contact.tasks)

#===================

from amocrm import BaseLead, LeadTask, amo_settings

amo_settings.set('*****@*****.**', '4b332718c4c5944003af7e6389860ced',
                 'testcentrobit')

lead = BaseLead(name=u'some name')
lead.save()
task = LeadTask(lead=lead,
                text='123',
                type=u'Звонок',
                complete_till=datetime.datetime.now() +
                datetime.timedelta(days=3))
task.save()
print(task.id)

leads = LeadTask.objects.all(modified_since=datetime.datetime.now() -
                             datetime.timedelta(days=1))